dynamic form import
dynamic form import
I am trying to create a dynamic dataTable from an ajax call that has input boxes in the second column like in this example:
https://datatables.net/examples/api/form.html
In the example the text boxes are hard coded. Can they be created dynamically?
Also, in the example, the button grabs only the input boxes. I will need to get the row data including the inputs. Is this possible?
here is a sample I threw together:
http://live.datatables.net/tunafeti/1/edit
This question has an accepted answers - jump to answer
Answers
You can use
columns.defaultContent
orcolumns.render
to render the inputs. If you want to populate the input with data from the row then usecolumns.render
.There are lots of ways to do this depending on your needs. Generally I like to update the Datatables data cache with the input changes. I updated your test case with a
columns.render
function to display a text input with the default being the data for that column.I added an event handler for the
position
input that updates the Datatables cache with the changed data. I updated theProcess Data
button to get all the rows withrows().data()
. Note the use oftoArray()
to turn the result into a Javascript array.http://live.datatables.net/tunafeti/2/edit
Kevin
yes, this was awesome. thank you so much!!