unsuccessfully using afnFiltering

unsuccessfully using afnFiltering

fbasfbas Posts: 1,094Questions: 4Answers: 0
edited June 2011 in Plug-ins
I've followed the example at http://www.datatables.net/examples/plug-ins/range_filtering.html to create filtering on a date column (simple string comparisons of date string in format YYYY-MM-DD).

Debugger shows that routine is being called, and boolean results are what I expect, but results are not filtered out.

[code]
// main.js:377: // date filtering plug-in
$.fn.dataTableExt.afnFiltering.push(
function( oSettings, aData, iDataIndex ) {
var iMin = document.getElementById('daterecv_start').value;
var iMax = document.getElementById('daterecv_end').value;
if (!iMax) iMax = "99999";
var iValue = aData[get_column_number('datereceived')];

console.log( iValue, '>=', iMin, iValue >= iMin, " / ", iValue, '<=', iMax, iValue <= iMax, " // " , iValue >= iMin && iValue <= iMax);
return iValue >= iMin && iValue <= iMax;
}
);
[/code]

debugger output:
[code]
1997-10-01 >= 2001 false / 1997-10-01 <= 99999 true // false
1997-10-10 >= 2001 false / 1997-10-10 <= 99999 true // false
1997-12-09 >= 2001 false / 1997-12-09 <= 99999 true // false
1997-10-10 >= 2001 false / 1997-10-10 <= 99999 true // false
1997-03-25 >= 2001 false / 1997-03-25 <= 99999 true // false
1997-03-25 >= 2001 false / 1997-03-25 <= 99999 true // false
[/code]

I am using server side database controls.. does this conflict at all?

not sure what I'm missing.

code is at http://www.beg.utexas.edu/qa/ date input is in the "advanced search"

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    Still scratching my head, unable to get this to work, but I changed strategies and moved to using fnServerData / aoData.push( ) to add vars to the GET to the server side page. Works fine.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    HI fbas,

    [quote]fbas said: I am using server side database controls.. does this conflict at all? [/quote]

    Yes very much! With server-side processing DataTables doesn't do anything with the data given to it by the server, other than to simply display it. All filtering, sorting etc much be done by the server where the full dataset is. For example, imagine if the server returned 10 results for each page, but on one particular page the filtering applied on the client-side (if it worked that way) didn't match a single row - no results would be shown on a perfectly valid page. The server wouldn't know otherwise and neither would DataTables.

    As such, if using server-side processing, all the filtering etc must be done with the full dataset on the server. DataTables is just a dumb display and event handler when using server-side processing!

    Regards,
    Allan
This discussion has been closed.