Disable request on page load
Disable request on page load
Hello,I am new to datatables and I have a question.I have the next code:
[code]
var search;
var oTable = $(".dataTables").dataTable({
"iDisplayLength": 10,
"bProcessing": false,
"iDeferLoading": 10,
"bScrollCollapse": true,
"oLanguage": {
"sSearch": "Search all columns:",
"sZeroRecords": "Test1",
"sEmptyTable": "Test2"
},
"bServerSide": true,
"sAjaxSource": "link_here",
"aoColumns": [{"sWidth":"60%"},{"sWidth":"20%"},{"sWidth":"20%"}],
"fnServerData": function( sUrl, aoData, fnCallback ) {
if(search==true) {
aoData.push({"name":"sSearch_0", "value":$("#test_ci").val() });
$.ajax( { "url": sUrl, "type": "GET", "data": aoData, "success": fnCallback, "dataType": "json", "cache": true, "async": true } );
}
search=true;
}
});
[/code]
The table is not pre-populated on pageload and after I hit the search results appear.I receive my data correctly and everything works as expected.But when I delete everything I typed from search input 10 entries remain. I want the results to come back to initial state (0 entries).
[code]
var search;
var oTable = $(".dataTables").dataTable({
"iDisplayLength": 10,
"bProcessing": false,
"iDeferLoading": 10,
"bScrollCollapse": true,
"oLanguage": {
"sSearch": "Search all columns:",
"sZeroRecords": "Test1",
"sEmptyTable": "Test2"
},
"bServerSide": true,
"sAjaxSource": "link_here",
"aoColumns": [{"sWidth":"60%"},{"sWidth":"20%"},{"sWidth":"20%"}],
"fnServerData": function( sUrl, aoData, fnCallback ) {
if(search==true) {
aoData.push({"name":"sSearch_0", "value":$("#test_ci").val() });
$.ajax( { "url": sUrl, "type": "GET", "data": aoData, "success": fnCallback, "dataType": "json", "cache": true, "async": true } );
}
search=true;
}
});
[/code]
The table is not pre-populated on pageload and after I hit the search results appear.I receive my data correctly and everything works as expected.But when I delete everything I typed from search input 10 entries remain. I want the results to come back to initial state (0 entries).
This discussion has been closed.
Replies
Allan