bServerSide and _fnBuildSearchArray

bServerSide and _fnBuildSearchArray

icaroicaro Posts: 1Questions: 0Answers: 0
edited July 2011 in Bug reports
Hello Allan,

First of all, thank you for your hard work on bringing us this plugin.

My issue is the following:

I have a table displaying 3000 rows in pages of 10, 20, 50, 100, 500, 3000 and all the processing (paging/sorting/filtering) is done on the server side (i.e. bServerSide:true) using Linq (.NET) .

I ran into an issue today on IE7 (no surprise) while I was calling the fnFilterClear function: Every time a clicked a button to clear all the filters and regather the data from the server, the "processing..." message took longer to appear as more rows where displayed per page. For example on a 10-row page it would display the "processing..." message almost instantly but on a 500-row page the message took up to 3 or 4 seconds before appearing on the screen even though it should happen instantly since all fnClearFuntion does is clearing the input elements in the table page and calling _fnReDraw

Digging through the code I noticed that there's a check for bServerSide==true so that sorting and filtering is not performed on the client side unnecessarily; however, the last line in _fnFilterComplete is calling _fnBuildSearchArray regardless of the bServerSide setting. The interesting thing is that it is called after _fnCalculateEnd and _fnDraw are called.

My question would be: is the _fnBuildSearchArray call really necessary when bServerSide is set to true?

I modified my version as follows:

[code]
function _fnBuildSearchArray(oSettings, iMaster) {
if (!oSettings.oFeatures.bServerSide) {
/* Clear out the old data */
oSettings.asDataSearch.splice(0, oSettings.asDataSearch.length);

var aArray = (typeof iMaster != 'undefined' && iMaster == 1) ?
oSettings.aiDisplayMaster : oSettings.aiDisplay;

for (var i = 0, iLen = aArray.length; i < iLen; i++) {
oSettings.asDataSearch[i] = _fnBuildSearchRow(oSettings,
_fnGetRowData(oSettings, aArray[i], 'filter'));
}
}
}
[/code]

And works as expected without this weird delay on IE7.

I am using datatables v 1.8.1.

Thanks,

Ricardo.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Ricardo,

    Excellent point! _fnBuildSearchArray basically doesn't really serve any propose with server-side processing since the filtering is done on the server-side, so taking this out here sounds like a very good plan to me.

    I'll include your change in the next DataTables release. Thanks very much for your post!

    Regards,
    Allan
This discussion has been closed.