How to Form a datatable with server processing?
How to Form a datatable with server processing?
Hi, How to form a datatable with server side processing?
This is my Datatable code :
$(document).ready(function() {
var table = $('#myTable').DataTable({
"serverSide": true,
"processing": true,
"paging": true,
"searching": {
"regex": true
},
"lengthMenu": [
[10, 25, 50, 100, -1],
[10, 25, 50, 100, "All"]
],
"pageLength": 10,
ajax: {
url: "/external/getdealers",
dataSrc: "data"
},
columns: [{
data: '_id',
}, {
data: 'DealerType'
}, {
data: 'Address'
}, {
data: 'CompanyName',
"defaultContent": "Not Yet Set",
}, {
data: 'Country'
}, {
data: 'DealerName',
"defaultContent": "Not Yet Set",
}, {
data: 'District'
}, {
data: 'Division',
}]
});
});
I am getting the details from server as :
data - [{_id: "58a2b51a1a9dfe3537a8c141", DealerType: "Seeds Producers & Mfg. Suppliers",…},…]
pagination - {total: 136358, limit: 100, page: "5", pages: 1364}
In data variable i am getting the data, and in pagination i am getting the total number of rows , limit per page , current page number, total pages.
Now i am able to show the data in userinterface, but for pagination i am getting like this > Showing 0 to 0 of 0 entries (filtered from NaN total entries)
and if i click on next page button through ajax call i am getting data like this >GET /external/getdealers?draw=3&columns%5B0%5D%5Bdata%5D=id&columns%5B0%5D%5Bname%5D=&columns%5B0%5D%5Bsearchable%5D=true&columns%5B0%5D%5Borderable%5D=true&columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B1%5D%5Bdata%5D=DealerType&columns%5B1%5D%5Bname%5D=&columns%5B1%5D%5Bsearchable%5D=true&columns%5B1%5D%5Borderable%5D=true&columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B2%5D%5Bdata%5D=Address&columns%5B2%5D%5Bname%5D=&columns%5B2%5D%5Bsearchable%5D=true&columns%5B2%5D%5Borderable%5D=true&columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B3%5D%5Bdata%5D=CompanyName&columns%5B3%5D%5Bname%5D=&columns%5B3%5D%5Bsearchable%5D=true&columns%5B3%5D%5Borderable%5D=true&columns%5B3%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B3%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B4%5D%5Bdata%5D=Country&columns%5B4%5D%5Bname%5D=&columns%5B4%5D%5Bsearchable%5D=true&columns%5B4%5D%5Borderable%5D=true&columns%5B4%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B4%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B5%5D%5Bdata%5D=DealerName&columns%5B5%5D%5Bname%5D=&columns%5B5%5D%5Bsearchable%5D=true&columns%5B5%5D%5Borderable%5D=true&columns%5B5%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B5%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B6%5D%5Bdata%5D=District&columns%5B6%5D%5Bname%5D=&columns%5B6%5D%5Bsearchable%5D=true&columns%5B6%5D%5Borderable%5D=true&columns%5B6%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B6%5D%5Bsearch%5D%5Bregex%5D=false&columns%5B7%5D%5Bdata%5D=Division&columns%5B7%5D%5Bname%5D=&columns%5B7%5D%5Bsearchable%5D=true&columns%5B7%5D%5Borderable%5D=true&columns%5B7%5D%5Bsearch%5D%5Bvalue%5D=&columns%5B7%5D%5Bsearch%5D%5Bregex%5D=false&order%5B0%5D%5Bcolumn%5D=0&order%5B0%5D%5Bdir%5D=asc&start=20&length=10&search%5Bvalue%5D=&search%5Bregex%5D=false&=1487151725059
Please help me, Thanks in advance !!