Update all tables when 1 bLengthChange value is changed

Update all tables when 1 bLengthChange value is changed

drewhjavadrewhjava Posts: 9Questions: 0Answers: 0
edited June 2011 in DataTables 1.8
Hey guys. This is my datatable code

[code]
$('.reportTable').each(function() {

var pkgLineId = $(this).attr('title');

var reportTable = $(this).dataTable({

"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bPaginate": true,
"bLengthChange": true,
"bFilter": false,
"bSort": false,a
"bInfo": true,
"bAutoWidth": false,
"bProcessing": true,
"bServerSide": true,
"sDom": '<"H"lfrp>t<"F"lip>',
"iDisplayLength": 15,
"aLengthMenu": [[10, 15, 20, 50, 100, 200, 500], [10, 15, 20, 50, 100, 200, 500]],
"aoColumns": [
{
"bVisible": false
},
null,
null,
null,
null,
null,
null
],
"sAjaxSource": '/json/reportData/'+pkgLineId,
"fnDrawCallback": function() {
var nodes = reportTable.fnGetNodes();
var lineStatus;
for (var i = 0; i < nodes.length; i++) {
lineStatus = reportTable.fnGetData(nodes[i]);
nodes[i].setAttribute("style", "background: " + lineStatus[0]);
}
}
});
});
[/code]

I have several tables on one page. If someone changes length of one I want to change the length of all of the tables on the page. I guess I'm looking for a callback for that change and then a datatable redraw. I think what makes it tricky is the server side processing. Thanks for the help.

Replies

  • drewhjavadrewhjava Posts: 9Questions: 0Answers: 0
    Bump?
  • allanallan Posts: 61,627Questions: 1Answers: 10,090 Site admin
    You would need a plug-in API function to do this I think. There isn't one currently available which will do exactly what you want, but it should be possible to base one of this plug-in which does basically the same as you want, but for filtering: http://datatables.net/plug-ins/api#fnFilterAll .

    Allan
  • drewhjavadrewhjava Posts: 9Questions: 0Answers: 0
    Hey Allan what is the callback when the length is changed? I can't seem to find it anywhere?
  • allanallan Posts: 61,627Questions: 1Answers: 10,090 Site admin
    When the display length is changed? There isn't one specifically for that, but you can use fnDrawCallback since the length changing will always result in a draw. If you want to ensure your action will only occur on a length change, then you can just add an 'if' condition to it ( oSettings._iDisplayLength ).

    Allan
This discussion has been closed.