Initialization question
Initialization question
Ive searched the forum for more than 1 hour now, without findin anythin. Im sure there is a thred on this basic matter but i just cant find it. To the question.
What method(s) should be used to initialize the datatable without ajax request. I need dataTables to apply the css etc.. to the table so i get the correct looks(layout) on the table without triggering the ajax call.
I Use fnDraw on my searchbutton click event.
What method(s) should be used to initialize the datatable without ajax request. I need dataTables to apply the css etc.. to the table so i get the correct looks(layout) on the table without triggering the ajax call.
I Use fnDraw on my searchbutton click event.
This discussion has been closed.
Replies
2. For CSS just link to page as other CSS using tag.
3. Can u show the code how you using fnDraw()?
Anjib
I see now that the question was not as clear as i thought. I am using Ajax, i just wanted to initialise the table before making ajax call. Trigger the ajax call from a button instead.
However i solved this easily. I looked through the source code and realized there is no method for this, so instead i used, fnServerData which overrides the default ajax call. In fnServerData i check if a flag is set, if it is i make the call.
example.
[code]
"sAjaxSource": "http://<%=Request.ServerVariables.Get("SERVER_NAME") %>/XXX/XXX.asmx/GetTable",
"fnServerData": function ( sSource, aoData, fnCallback ) {
if(TableInitializationIsReady){ //CHECKS IF WE SHOULD MAKE THE AJAX CALL
$("#imgprocess").show();
$("#<%=ClientID %>_txtSettingsForExcel").val("{" + filtervalues + "}");
$.ajax({
"contentType": "application/json; charset=utf-8",
"type": "POST",
"url": sSource,
"data": cData,
"dataFilter": function(data) {
var msg = eval('(' + data + ')');
if (msg.hasOwnProperty('d'))
return msg.d;
else
return msg;
},
"success": function (data, textStatus) {
if(data.Error != ""){
alert("Error" + data.Error);
}
else{
fnCallback.call(textStatus,data.oData);
}
$("#imgprocess").hide();
if(loadFilters == true){
getFilters();
loadFilters = false;
}
}
});
}
}
[/code]