When adding a row dynamically using jQuery DataTables plugin, what do I do if one of the cells has to be, say, a checkbox? Just put the HTML in quotes?
A column can be shown with a checkbox that reflects the row's selected status simply through the use of the select-checkbox CSS class for that column ( columns. className ). Row selection can be restricted to that column using the select. selector option.
function uncheckRow(trId) {<br> var table = $('#example'). DataTable(); var row = table. row("#"+trId); var rowData = row. data(); var name = rowData[1]; var age = rowData[2]; // need to check if the check box in the 1st column(rowData[0]) is checked or not, If it is checked, i have to uncheck … }
Ok now I know it is the plugin that I am using.
I did mine on the server but you should just write the html in the column.
I will try to make an example in a few minutes.
This is how my checkbox comes from the server
"CheckBox":"\u003cinput type=\"checkbox\"\u003e\u003c/input\u003e"
However this should work
dataTable.fnAddData(['<input type="checkbox" name="vehicle" value="Bike" />','SomeOtherDataForAnotherColumn']);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With