Datatables multiple select afnFiltering
I have multiple select menus which are used to filter a table using jquery
datatables.
The following code i use works brilliant, but for this example I am only
using 3 select menus. I now have a table which will be using upwards of
10.
Is there a better way of writing this so I don't have to write every
variation of matches.
$.fn.dataTableExt.afnFiltering.push(
function( oSettings, aData, iDataIndex ) {
if ( oSettings.nTable == document.getElementById( 'logtable' ))
{
var nature_of_complaint =
document.getElementById('nature_of_complaint_select').value;
var division = document.getElementById('division_select').value;
var resolved = document.getElementById('resolved_select').value;
var tabledata_nature_of_complaint = aData[22];
var tabledata_division = aData[12];
var tabledata_resolved = aData[26];
if (nature_of_complaint == "" && division == "" && resolved == "")
{ return true; }
else if (tabledata_division == division && nature_of_complaint
== "" && resolved == "")
{ return true; }
else if (tabledata_nature_of_complaint == nature_of_complaint &&
division == "" && resolved == "")
{ return true; }
else if (tabledata_resolved == resolved && division == "" &&
nature_of_complaint == "")
{ return true; }
else if (tabledata_nature_of_complaint == nature_of_complaint &&
tabledata_division == division && resolved == "")
{ return true; }
else if (tabledata_division == division && tabledata_resolved ==
resolved && nature_of_complaint == "")
{ return true; }
else if (tabledata_resolved == resolved &&
tabledata_nature_of_complaint == nature_of_complaint && division
== "")
{ return true; }
else if (tabledata_nature_of_complaint == nature_of_complaint &&
tabledata_division == division && tabledata_resolved ==
resolved)
{ return true; }
return false;
} else
return true;
}
);
No comments:
Post a Comment