Checkbox in my first DataTables project

Checkbox in my first DataTables project

WirajWiraj Posts: 1Questions: 1Answers: 0

Good morning,

I would like to know how can I create a checkbox group that filters inside the DataTable.
At the moment it's working fine, but when I use the checkbox it shows the results, but it's "broken" in the DataTable, without ordering, pagination, filters, etc.

I know I can put the checkboxes inside the table, but I would like to put it in the left side of the web and the results on the right side.

That's my URL: http://bdebeauty.es/index.php?option=com_jumi&view=application&fileid=14&Itemid=258

That's my script:

function makeTable(data){ var tbl_body = ""; $.each(data, function() { var tbl_row = ""; $.each(this, function(k,v) { tbl_row += ""+v+""; }) tbl_body += ""+tbl_row+""; }) return tbl_body; } function getEmployeeFilterOptions(){ var opts = []; $checkboxes.each(function(){ if(this.checked){ opts.push(this.name); } }); return opts; } function updateEmployees(opts){ $.ajax({ type: "POST", url: "submit.php", dataType : 'json', cache: false, data: {filterOpts: opts}, success: function(records){ $('#employees tbody').html(makeTable(records)); // here, after the content is inside DOM/visible we activate the plugin $('#employees').dataTable({ "paging": true, "ordering": false, "info": false, "searching": false, "pageLength": 15, "lengthChange": false }); } }); } var $checkboxes = $("input:checkbox"); $checkboxes.on("change", function(){ var opts = getEmployeeFilterOptions(); updateEmployees(opts); }); updateEmployees();

Thanks,

Regards.

This discussion has been closed.