De-duplicating table redraws
De-duplicating table redraws
Greetings all,
I have a page that uses datatables to display two sets of information. I have a series of buttons that allow the user to filter data.
The buttons change some state variables and call an Update routine. Based on the state, the Update routine may hide or show a column [ fnSetColumnVis ], clear the search filter [ fnFilter("") ] or just call fnDraw [ fnDraw() ]
The problem I'm trying to solve is that if the column show/hide state changes, the fnSetColumnVis makes an Ajax call to the server; when I get to the fnDraw/fnFilter code, it draws again. I'd like to remove the extra call to the server for efficiency purposes.
Is there a way to tell fnSetColumnVis not to re-draw, or combine all the changes to Datatables into one call?
Thanks
-Jimmy
I have a page that uses datatables to display two sets of information. I have a series of buttons that allow the user to filter data.
The buttons change some state variables and call an Update routine. Based on the state, the Update routine may hide or show a column [ fnSetColumnVis ], clear the search filter [ fnFilter("") ] or just call fnDraw [ fnDraw() ]
The problem I'm trying to solve is that if the column show/hide state changes, the fnSetColumnVis makes an Ajax call to the server; when I get to the fnDraw/fnFilter code, it draws again. I'd like to remove the extra call to the server for efficiency purposes.
Is there a way to tell fnSetColumnVis not to re-draw, or combine all the changes to Datatables into one call?
Thanks
-Jimmy
This discussion has been closed.
Replies
[code]
$("#updateBtn").click(function (e) {
e.preventDefault();
if ($('#assignedWorker_visible').val() == 'true') {
$("#availAssignTable").dataTable().fnSetColumnVis( 0, true );
} else {
$("#availAssignTable").dataTable().fnSetColumnVis( 0, false );
}
if ($('#signin_visible').val() == 'true') {
$("#signinTab").show();
} else {
$("#signinTab").hide();
}
//alert($("#signinTable").dataTable().fnFilter());
if ($('#signinTable_filter').val() == null) {
$("#signinTable").dataTable().fnDraw();
} else {
$("#signinTable").dataTable().fnFilter("");
}
if ($('#availAssignTable_filter').val() == null) {
$("#availAssignTable").dataTable().fnDraw();
} else {
$("#availAssignTable").dataTable().fnFilter("");
}
});
[/code]
http://datatables.net/api#fnSetColumnVis (3rd parameter)
fnFilter ( http://datatables.net/api#fnFilter ) however does not have such an option. It would be possible to construct a plug-in API method which sets the filtering and then doesn't act upon that filter until a full draw is done next, but there currently isn't a built-in way of doing that.
Regards,
Allan
-Jimmy