fnDraw - Change in behavior since 1.8.2
fnDraw - Change in behavior since 1.8.2
bartman
Posts: 5Questions: 0Answers: 0
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!
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!
This discussion has been closed.
Replies
I've had a scan through the infinite scrolling code and can't see what would be causing the problem I'm afraid.
Allan
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."
Allan
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!