Stop DataTables from requesting data on first view
Stop DataTables from requesting data on first view
DanielShine
Posts: 1Questions: 1Answers: 0
Hello,
I want Datatables to run only when pressing a "submit" buttom, which is this one:
The problem is that when I open the view where this filter is, datatables looks like this: (Clearly I haven't given it any data to load)
This is my code:
url = location.search;
var table = $('.data-table').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"sDom": '<""lri>t<"F"fp>',
"aaSorting": [],
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": "/ledger/ajax"+url,
"fnServerParams": function(aoData) {
},
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
// console.log(nRow);
// console.log(aData);
},
"aoColumns": [
{ "mDataProp": "fecha" },
{ "mDataProp": "cuentaContable" },
{ "mDataProp": "nombreCuentaContable" },
{ "mDataProp": "comentarios" },
{ "mDataProp": "line_cargo" },
{ "mDataProp": "line_abono"}
],
"oLanguage": {
"sUrl": "/js/language/" + js_lang + ".txt"
},
"bStateSave": true
});
I'm using DataTables 1.9
Thanks
This discussion has been closed.
Answers
Could you just not initialise the DataTable until the submit happens? You could also hide the table until that time.
Allan