Filtering data with a time range, date range, input and select in server side

Filtering data with a time range, date range, input and select in server side

mf_a2ifmf_a2if Posts: 32Questions: 0Answers: 0
edited January 2013 in Plug-ins
Hi all,

Today, I have found how filtering datatable with column filter with time range (in select and format time hh:mm:ss), date range (datepicker format date yy-mm-dd), input and select, in server side processing.

For thoose who are interested :)

Modify jquery.dataTables.columnFilter.js at line 174, function fnCreateRangeInput :
[code]
function fnCreateRangeInput(oTable, oSelect, aData) {
th.html(_fnRangeLabelPart(0));
var sFromId = oTable.attr("id") + '_range_from_' + i;
// Si on est sur un input normal
if(oSelect == "") var from = $('');
else {
var from = '';
var j = 0;
var iLen = aData.length;
for (j = 0; j < iLen; j++){
if (typeof (aData[j]) != 'object') from += '' + aData[j] + '';
else from += '' + aData[j].label + '';
}
from += '';
}
th.append(from);
th.append(_fnRangeLabelPart(1));
var sToId = oTable.attr("id") + '_range_to_' + i;
if(oSelect == "") var to = $('');
else {
var to = '';
var j = 0;
var iLen = aData.length;
for (j = 0; j < iLen; j++){
if (typeof (aData[j]) != 'object') to += '' + aData[j] + '';
else to += '' + aData[j].label + '';
}
to += '';
}
th.append(to);
th.append(_fnRangeLabelPart(2));
th.wrapInner('');
var index = i;
aiCustomSearch_Indexes.push(i);

... NEXT DOESN'T CHANGE ...
[/code]

Modify jquery.dataTables.columnFilter.js at line 650, case "number-range" :
[code]
case "number-range":
fnCreateRangeInput(oTable, "", "");
break;
case "time-range":
fnCreateRangeInput(oTable, "select", aoColumn.values);
break;
[/code]

Code JS :
[code]
$(document).ready(function() {
// Affichage du tableau avec le détail des entrées
$('#tabDetail').dataTable({
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"aButtons": [/*"copy",*/ {
"sExtends": "download",
"sButtonText": "EXCEL",
"sUrl": "generer_csv.php"
},{
"sExtends": "download",
"sButtonText": "PDF",
"sUrl": "generer_pdf.php"
}, "print"]
},
"sAjaxSource": "serverSide_general.php",
"fnServerData": function( sUrl, aoData, fnCallback ) {
$.ajax( {
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "json",
"cache": false
} );
}
}).columnFilter({
aoColumns: [
{ type: "input" },
{ type: "date-range" },
{ type: "time-range" , values: ["07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19"]},
{ type: "select", values: ['muret', 'labarthe']}]
});
[/code]

Code serverSide_general.php :
[code]
/* Individual column filtering */
for ( $i=0 ; $i
This discussion has been closed.