DataTables and Rails 3.0.x question

DataTables and Rails 3.0.x question

mklemmklem Posts: 1Questions: 0Answers: 0
edited November 2011 in DataTables 1.8
Hello.

Great plugin. Thank you.

I am using DataTables to list my data which is working fine. I am displaying various input types on each row, like text fields, checkboxes, select menus. I noticed that the data is not saved when the form is submitted. Instead new rows are added. I found out why.

Without using DataTables, after each tr element, Rails adds a hidden input to track the id of the record for each row. Something like this:


When using DataTables, this data is removed.

My question is, am I using DataTables incorrectly? Is it only intended to display data and not handle inputs?

Is there a better way to do this?

Thanks

Replies

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    DataTables was designed to display data, but that's no reason why it can't be used to do forms (indeed, forms are using successfully with DataTables in a lot of places - for example: http://datatables.net/blog/Inline_editing .

    So the question is - how are you telling DataTables that data has been modified or updated? You need to use the API to do this: http://datatables.net/api - specifically fnAddData and fnUpdate. Otherwise DataTables doesn't know that a row has been added / removed / edited.

    Allan
This discussion has been closed.