Tag Archives: jQuery DataTables

[Solved] Query DataTables Error: Cannot reinitialise DataTable

Solution: destroy: true

Var tab = $(‘#userlist’). Datatable ({
Destroy: true,// add this attribute to
bprocessing: true,// whether DataTables will display the “progress” prompt when loading data
bstatesave: false,// whether to turn on the client status recording function, When Ajax refreshes records, this function will not return the personalization settings to the initialization state
alengthmnu: [10, 20, 40, 60, 100, 1000]// change the display record number option
idisplaylength: 10,// default display record number
binfo: true,// display the page header information, DataTables plug-in displays record number in the lower left corner
bpaginate: true, //Display (apply) pager
autowidth: true,// adaptive width
bscrollcollapse: true,// enable height adaptation of DataTables. When the number of data is less than the number of paging data, does the plug-in height change with the number of data
spaginationtype: “full”_ Numbers “,// detailed pagination group, which can directly jump to a page
bsort: false,// whether to start the sorting function of each field
bfilter: true,// whether to start the filtering and search function
bserverside: true,// after this mode is turned on, how many records, next page, previous page, sorting (header), search are displayed on each page of DataTables, These will be passed to the server corresponding values
“ajax”: {
url: “/Ajax/UserMgrAjax.ashx?cmd=userList”,
type: “POST”

},
columns: [
{
“sWidth”: “4%”,
“sClass”: “text-center”,
“data”: null,
“targets”: 0
},
{
“sWidth”: “4%”,
“sClass”: “text-center”,
“data”: “u_ ID “,
” render “: function (data, type, full, meta) {//here is the check box multi selection box to be displayed

return ‘& lt; input type=”checkbox” class=”checkchild” value=”‘ + data + ‘” />’;
},
“bSortable”: false
},

{ “sClass”: “text-center”, “data”: “u_ name” },
{ “sClass”: “text-center”, “data”: “u_ tel” },
{
“sClass”: “text-center”,
“data”: “u_ “Sex”,
“render”: function (data, type, row, meta) {

var content = “confidentiality”
if (data = = 1)
content = = male
if (data = = = 2 “)
content = female
return content;
}

},
{ “sClass”: “text-center”, “data”: “u_ age” },
{ “sClass”: “text-center”, “data”: “u_ registerdate” },
{
“sClass”: “text-center”,
“data”: “u_ State “,
” render “: function (data, type, row, meta) {
var content =” abnormal ”
if (data = = 0)
content = = normal
if (data = = = 1 “)
content = lock
return content;
}
},
{
“sClass”: “text-center”,
“data”: “u_ registerdate”,
render: function (data, type, row, meta) {

return “< A id =’edit ‘title =’edit’ class =’glyphicon glyphicon edit nounderline ‘ avascript:Edit (“+row.u_ id+”);’>& lt;/ a>”;<
}
}

],
// this should be the redrawcallback function
fndrawcallback: function() {
var StartIndex = this. Api(). Context [0]_ iDisplayStart;// Get the number of entries at the beginning of this page
this. API (). Column (0). Nodes (). Each (function (cell, I) {
// page turning sequence number is continuous
cell.innerhtml = StartIndex + I + 1

});
},
});