Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery DataTables plugin: adding a checkbox dynamically

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?

like image 483
bmargulies Avatar asked Aug 09 '10 21:08

bmargulies


People also ask

How to add checkbox in DataTable column?

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.

How check checkbox is checked or not in jquery DataTable?

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 … }


1 Answers

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']);
like image 184
chobo2 Avatar answered Oct 06 '22 01:10

chobo2