How do I filter tableresults on checkbox.change()
How do I filter tableresults on checkbox.change()
Mech0z
Posts: 1Questions: 0Answers: 0
I have datatable, I want to filter so that when a checkbox is checked it all results are shown, but when the checkbox is "checked" then it can only show results where oObj.aData[5] is "" or null.
[code]
var table;
function createDataTable() {
table = $('#resource_table').dataTable({
"bProcessing": true,
"sPaginationType": "full_numbers",
"sDom": '<"H"lrf>t<"F"pi>',
"bJQueryUI": true,
"bServerSide": true,
"sAjaxSource": GetAbsolutePath("Resource/ProccessDataTableQuery"),
"iDisplayLength": 5,
"fnServerData": function (sSource, aoData, fnCallback) {
$.getJSON(sSource, aoData, function (json) {
fnCallback(json);
});
},
"aLengthMenu": [[5, 10, -1], [5, 10, 'All']],
"aoColumnDefs": [
{
"fnRender": function (oObj) {
var retVal =
'' +
' ' + oObj.aData[0] + ' ' + oObj.aData[1] + '' +
' SAR Unit: ' + oObj.aData[2] + '' +
' Status: ' + oObj.aData[8] + '' +
' ' +
' OOS since: ' + oObj.aData[4] + '' +
' Remarks: ' + oObj.aData[7] + '' +
' Notes: ' + oObj.aData[3] + '' +
' Returned time:' + oObj.aData[5] + '' +
' Expected return was ' + oObj.aData[6] + '' +
' ' +
'';
return retVal;
},
"aTargets": [0]
},
{ "bVisible": false, "aTargets": [1] },
{ "bVisible": false, "aTargets": [2] },
{ "bVisible": false, "aTargets": [3] },
{ "bVisible": false, "aTargets": [4] },
{ "bVisible": false, "aTargets": [5] },
{ "bVisible": false, "aTargets": [6] },
{ "bVisible": false, "aTargets": [7] },
{ "bVisible": false, "aTargets": [8] },
{ "bVisible": false, "aTargets": [9] }
]
});
};
[/code]
[code]
var table;
function createDataTable() {
table = $('#resource_table').dataTable({
"bProcessing": true,
"sPaginationType": "full_numbers",
"sDom": '<"H"lrf>t<"F"pi>',
"bJQueryUI": true,
"bServerSide": true,
"sAjaxSource": GetAbsolutePath("Resource/ProccessDataTableQuery"),
"iDisplayLength": 5,
"fnServerData": function (sSource, aoData, fnCallback) {
$.getJSON(sSource, aoData, function (json) {
fnCallback(json);
});
},
"aLengthMenu": [[5, 10, -1], [5, 10, 'All']],
"aoColumnDefs": [
{
"fnRender": function (oObj) {
var retVal =
'' +
' ' + oObj.aData[0] + ' ' + oObj.aData[1] + '' +
' SAR Unit: ' + oObj.aData[2] + '' +
' Status: ' + oObj.aData[8] + '' +
' ' +
' OOS since: ' + oObj.aData[4] + '' +
' Remarks: ' + oObj.aData[7] + '' +
' Notes: ' + oObj.aData[3] + '' +
' Returned time:' + oObj.aData[5] + '' +
' Expected return was ' + oObj.aData[6] + '' +
' ' +
'';
return retVal;
},
"aTargets": [0]
},
{ "bVisible": false, "aTargets": [1] },
{ "bVisible": false, "aTargets": [2] },
{ "bVisible": false, "aTargets": [3] },
{ "bVisible": false, "aTargets": [4] },
{ "bVisible": false, "aTargets": [5] },
{ "bVisible": false, "aTargets": [6] },
{ "bVisible": false, "aTargets": [7] },
{ "bVisible": false, "aTargets": [8] },
{ "bVisible": false, "aTargets": [9] }
]
});
};
[/code]
This discussion has been closed.