fnDraw - Change in behavior since 1.8.2

fnDraw - Change in behavior since 1.8.2

bartmanbartman Posts: 5Questions: 0Answers: 0
edited February 2012 in DataTables 1.9
Upgraded to 1.9.0 from 1.8.2.

The only code changes made was the removal of the row return for fnRowCallback. All other client side code and all server side code is exactly the same. This doesn't mean it was right under the 1.8.2 configuration, but it did work.

Under 1.8.2, when issuing an fnDraw command, if the filter set changed, the table would properly redraw, the previous rows would automatically be deleted by the new rows inserted. Under 1.9.0, the original rows remain and the new rows are appended to the end of the table.

dataTable settings:
[code]
"bProcessing": true,
"bServerSide": true,
"bPaginate": false,
"bScrollInfinite": true,
"bScrollCollapse": true,
"bJQueryUI": true,
"sDom": "rt",
"sScrollY": $("#ProductsListDiv").height()-20,
"oLanguage": { "sEmptyTable": "No Products found!" },
"sAjaxSource": "products/",
"fnServerData" : function ( sSource, aoData, fnCallback ) {
$.ajax({
"dataType": "json",
"type": "POST",
"url": sSource,
"data": aoData,
"success": function(result){
$("#infobox").html("Products found: "+result["iTotalRecords"]+"");
fnCallback(result);
console.log(result);
}
});
},
"fnServerParams" : function ( aoData ) {
aoData.push( { "name":"action", "value": "list" } );
aoData.push( { "name":"iDisplayStart", "value": this.fnSettings().aiDisplay.length } );
aoData.push( { "name":"filters", "value": $("#ProductsFilterForm").serialize() } );
},
"aoColumns": $options['columns']
[/code]

Note the console.log and the info box statments, the result is valid json and the correct new rows are being returned.
dataTables just is not removing the previous row set as it did under 1.8.2.

Any help is much appreciated!

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Interesting! I've just been experimenting a bit with this example: http://datatables.net/release-datatables/examples/basic_init/scroll_y_infinite.html and I've not been able reproduce the problem I'm afraid. How are you calling fnFilter? Certainly calling fnFilter should cause a full refiltering and all nodes be removed and replaced.

    I've had a scan through the infinite scrolling code and can't see what would be causing the problem I'm afraid.

    Allan
  • bartmanbartman Posts: 5Questions: 0Answers: 0
    edited February 2012
    [quote]How are you calling fnFilter?[/quote]

    I was calling fnDraw only. This worked under 1.8.2.

    Calling fnFilter with an empty string parameter pushes the form (line 27 of the config quoted) which for some reason I thought I had to use fnDraw to accomplish.

    To quote Gilda Radner... "Ohhh... nevermind."
  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Interesting that there is a difference between the two versions here. I've just tried my experiment again, with fnDraw this time - scroll to the bottom of an infinite table, call fnDraw and it jumps back to the top. Is this what you were expecting?

    Allan
  • bartmanbartman Posts: 5Questions: 0Answers: 0
    [quote] I've just tried my experiment again, with fnDraw this time - scroll to the bottom of an infinite table, call fnDraw and it jumps back to the top. Is this what you were expecting? [/quote]

    I was expecting fnDraw to remove all previous rows if iTotalRecords changed. Jumping to the top is ALSO expected, but that works.

    I switched to using fnFilter and I get the desired behavior, but there is something different between the two version.

    Thanks!
This discussion has been closed.