Get number input value from cell in a selected row
Get number input value from cell in a selected row
I'm using datatables to list a bunch of selectable rows to pass that data to a form via jQuery.
I'm currently using "table.rows( { selected: true } ).data()" to get the selected rows data, which works, with the exception of getting the data from the number input in one of the columns.
If I get the value from the column, it just returns the HTML from that cell, not the actual value. Additionally when the number input changed, that doesn't reflect in the HTML value as that's stored in the DOM and I can't access it that way.
The number input is basically a quantity field, and I want to pass what rows are selected and a quantity field to go with it.
Thanks in advance!
Answers
Because it is a live DOM input, you need to use
row().node()
(orcell().node()
) to get the DOM element for the row / cell, and then query it to get the value.You could do that in
iterator()
to build up the return object: https://live.datatables.net/qolosovi/1/edit .The other option is to use
rows().every()
which is a little easier to work with, but it doesn't do anything with the return value, so you'd need to build up the object manually.Allan