Migrate to DataTables 1.10 - fnServerData
Migrate to DataTables 1.10 - fnServerData
soltest
Posts: 3Questions: 1Answers: 0
The (old to new) mapping for both sAjaxSource and fnServerData is ajax: 1.9 to 1.10 Mapping
How can I convert the following DataTables initialization from 1.9 to 1.10?
(Just for these 2 options: sAjaxSource and fnServerData)
customersTable = $('#CustomersGrid').DataTable({
"jQueryUI": true,
"serverSide": true,
"sAjaxSource": "/Division/TX/GetAllCustomers",
"fnServerData": function (sSource, aoData, fnCallback) {
$.getJSON(sSource, aoData, function (json) {
fnCallback(json);
});
}, ...
This discussion has been closed.
Answers
sAjaxSource maps to ajax.dataSrc (http://datatables.net/reference/option/ajax.dataSrc ) and I'm fairly certain that the fnServerData maps to the callback feature inside the ajax method (half way down the page at http://datatables.net/reference/option/ajax ). So my understanding of how this would look after the translation is
If it works let me know. I've been putting off transitioning my syntax from old to new because I wasn't sure about some of the same stuff.
How do you define the callback function INSIDE the ajax object?
It doesn't work the way it is specified above.
The link I gave shows some examples of how to define the callback. I did forget the function declaration on it though. I will say that the link doesn't show how to use the two together, so I can't give a better example, you'll just have to look at the link and piece it together.
Any solutions to this? The conversion table to 1.10 does not explain how OP's table would be converted to 1.10.
apparently, OP's "fnServerData" function does nothing necessary. fnServerData is a pre-defined function and OP's doesn't override any default behaviour...
so as far as i can see:
would probably work the same in OP's case.
my 1.9 method:
became: