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?

davidshidavidshi Posts: 1Questions: 0Answers: 0
edited March 2012 in General
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]

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Internally it can't - however, you would set a flag in whatever is calling fnClearTable that your server data function would listen for ( isClearTable = true; for example).

    Allan
This discussion has been closed.