How does can my fnServerData function determine if it's being called as part of fnClearTable call?
How does can my fnServerData function determine if it's being called as part of fnClearTable call?
I noticed my table was making an ajax request multiple times when I click a button in my ui which first calls fnClearTable then calls fnDraw. I set a breakpoint in my fnServerData call and found that fnClearTable is on the stack in the first call, then it's called again during fnDraw. Is this by design? If so, is there any information in aoData I can use to determine that it's clearing the table an it should return empty data?
[code]
$(this).find("table").dataTable(
{
"bAutoWidth": true,
"bFilter": false,
"bInfo": false,
"bServerSide": true,
"sAjaxDataProp": "results",
"bPaginate": false,
"sAjaxSource": $(".grid-tabs").data("service-url"),
"aoColumns": getColumns(entity),
"bDeferRender": true,
"fnServerData": function (sUrl, aoData, fnCallback) {
OData.request({
enableJsonpCallback: true,
requestUri: sUrl + buildQuery(entity, true),
method: "GET"
},
function (data, response) {
fnCallback(data);
$("div.querygrid-tab[data-entity-name='" + entity + "'] aside.display-count .displayed-record-count").text(tables[entity].$("tr").length);
},
function (error) {
tokenManager.update();
});
}
});
[/code]
[code]
$(this).find("table").dataTable(
{
"bAutoWidth": true,
"bFilter": false,
"bInfo": false,
"bServerSide": true,
"sAjaxDataProp": "results",
"bPaginate": false,
"sAjaxSource": $(".grid-tabs").data("service-url"),
"aoColumns": getColumns(entity),
"bDeferRender": true,
"fnServerData": function (sUrl, aoData, fnCallback) {
OData.request({
enableJsonpCallback: true,
requestUri: sUrl + buildQuery(entity, true),
method: "GET"
},
function (data, response) {
fnCallback(data);
$("div.querygrid-tab[data-entity-name='" + entity + "'] aside.display-count .displayed-record-count").text(tables[entity].$("tr").length);
},
function (error) {
tokenManager.update();
});
}
});
[/code]
This discussion has been closed.
Replies
Allan