searchPanes error on default serverSide
searchPanes error on default serverSide
we0038
Posts: 45Questions: 15Answers: 1
I keep getting this error message:
ajax is null
on this filedatatables.js
on this line
else if (ajax.url === '') {
// No url, so don't load any data. Just apply an empty data array
// to the object for the callback.
var empty = {};
DataTable.util.set(ajax.dataSrc)(empty, []);
callback(empty);
}
After troubleshooting, I found out that having default value for serverSide is the reason
$.extend( true, $.fn.dataTable.defaults, {
serverSide: true,
});
how to fix this while keeping the default serverSide: true,
This question has an accepted answers - jump to answer
Answers
It sounds like you haven't defined
ajaxin the Datatables options. Server side processing requires the use ofajaxto fetch the data. If you are not usingajaxfor the table data then remove theserverSideoption.Kevin
I do use ajax for all of my tables. Also all of them are
serverSide: truethat's why I have that set in datatables default.Just today, I tried to use searchPanes for the first time and got that error.
The current solution is to remove
serverSide: truefrom$.fn.dataTable.defaultsand addserverSide: trueto each table initialisation but I does not make sense why it breaks when I set it as default!Sorry I missed the fact you are using SearchPanes. The default options are applied to all Datatables on the page. The SearchPanes tables are Datatables. I can think of two options:
serverSide: truefrom the default options and apply to all Datatables.searchPanes.dtOptsto setserverSideto false, for example:Kevin
Just realized you can do this:
For example:
https://live.datatables.net/qeguyota/1/edit
But it might not work if you are setting other
searchPanesoptions as I believe the default will be overwritten.Kevin
Thank you Kevin,
This solves the error message. However, searchPanes always empty.
I ended up removing
serverSide: true,from$.fn.dataTable.defaultsthen define it for each table individually.