I want to create a table with editable cells so that user can copy data from spreadsheet and paste data into this table. There will be some buttons below the table: 'insert' which can insert all the rows in the table into database; 'add a row(s)' which can add one or more empty rows into this table; and 'delete' which can delete the selected rows from the table. Could someone tell me if it is doable? If so, would you please give me some clues? I am new to drupal. Thank you very much!

Comments

xniu’s picture

I am still waiting for the help. Thanks!

wdmartin’s picture

What you really want is a datagrid element. Unfortunately, that's not currently supported in any browser that I know of, since it's still in working draft status.

There have been some attempts to use JavaScript to make datagrids out of tables:

http://dhtmlx.com/docs/products/dhtmlxGrid/
This one supports copying data FROM a grid, but not pasting INTO the grid.

http://www.codeproject.com/KB/scripting/Javascript_DataGrid.aspx
This one only works in IE, which is where I stopped reading.

It would be easier to do using a Java Applet, but then your users would have to have Java installed.

Basically, you have these options:

  1. Find a JavaScript implementation that meets your needs (iffy)
  2. Find a Java implementation that meets your needs (also iffy, and introduces a significant dependency for your app)
  3. Write your own JavaScript version (fiendishly difficult to do in a cross-browser compatible way)
  4. Write your own Java version
  5. Wait for the datagrid element to get widespread support (don't hold your breath, could take years)

Good luck! You'll need it.

xniu’s picture

Thank you very much! Now I know I have to give up and think of another way to do it.