i have a problem in datatable when draw the table using jquery from json string,
each time ($tableid).datatable is called a new filter and pagination row is added above the table.
followin my code used to create the table:
cshtml code:
| Country | City | Caza | Other | Edit | Delete |
|---|---|---|---|---|---|
| @address.Description | @address.City | @address.CAZA | @address.Address |
JQuery Code
this.ajaxAddressSuccess = function (result) {
if (typeof result !== 'undefined' || result.lenght > 0) {
var dataTable = [];
$.each(result, function (index, value) {
debugger;
dataTable.push([value["Country"], value["City"], value["Caza"], value["Other"], value["Edit"], value["Delete"]]);
});
$('.modalAddresstable')
.DataTable(
{
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [4] },
{ "bSortable": false, "aTargets": [5] }
],
data: dataTable
}
).draw();
}
else {
}
}
if (typeof result !== 'undefined' || result.lenght > 0) {
var dataTable = [];
$.each(result, function (index, value) {
debugger;
dataTable.push([value["Country"], value["City"], value["Caza"], value["Other"], value["Edit"], value["Delete"]]);
});
$('.modalAddresstable')
.DataTable(
{
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [4] },
{ "bSortable": false, "aTargets": [5] }
],
data: dataTable
}
).draw();
}
else {
}
}
Replies
Know the answer? Post it — somebody with the same question will find it here.