How to get the row data marked with a checkbox? (checkbox data, input field, etc.)
How to get the row data marked with a checkbox? (checkbox data, input field, etc.)
_Natasha_
Posts: 4Questions: 1Answers: 0
Hello! Faced the next problem.
I am using gyrocode's jQuery DataTables Checkboxes plugin (link https://www.gyrocode.com/projects/jquery-datatables-checkboxes/)
Question #1:
How to get the row data marked with a checkbox? (checkbox data, input field, etc.).
test case: https://live.datatables.net/tukusufu/3/edit
Question number 2:
How to make the number input field active only when this line is selected.
help me please
This question has accepted answers - jump to:
Answers
You'd need to ask Gyrocode - that plug-in isn't supported by us I'm afraid.
If you were using our own Select extension, then:
1) Use the API as described here
2) You could use Editor's inline editing perhaps?
Allan
One option is to enable the Select extension and enable the Gyrocode checkboxes selectRow option. Then use the
selector-modifier
of{selected: true}
with therows().data()
API to get the data of all selected rows. The updated example usesselect.selector
to limit row selection to just the checkbox.Start with the inputs as disabled, see the HTML table. Then use the
select
anddeselect
events to enable or disable theinput
as the rows or selected or deselected.https://live.datatables.net/tukusufu/4/edit
Kevin
Thanks for your reply. But unfortunately in your example the checkboxes behave unpredictably. And in the data, the input field is always empty.
That is a problem caused by using the Gyrocode checkboxes. You can ask for help from the developer. Or you can use remove that plugin and use this example to display the checkbox selection. See the updated example:
https://live.datatables.net/tukusufu/6/edit
I added the use of
columns.render
to display an empty string for thedisplay
type.Otherwise the
id
will be shown. See the Orthogonal data docs for details.Kevin
Checkboxes work , needed to change the .find('input') to .find('tinput[type="number"]').
But how to get the value of the input field of numbers?
returns only: "<input type=\"number\" name=\"row-2-price\" value=\"\" disabled=\"\">" ignoring entered number data
Change the loop to use
rows().every()
. In the loop you can get the row's data (row().data()
) and the row's node (row().node()
). Using the row's node you can get the input's value. Updated test case:https://live.datatables.net/payogege/1/edit
Kevin
Thanks a lot for your help!