I am also exploring the new usage of ableable1.10. If any error occurs in the following code, please submit it ..
1.10 and 1.9 difference official website Description: http://www.datatables.net/upgrade/1.10
Let's look at the code. Let's first look at the 1.9 statement:
$ (Document). Ready (function (){
VaR table, _ qdata;
Table = $ ('# example'). datatable ({
Aocolumns: _ tablecols,
Fncreatedrow: XXXXX, // function name
});
Loadlist ();
});
// table: Table object
function loadlist () {
$. ajax ({
URL: '/queryxx',
data: _ qdata,
datatype: 'json',
success: function (data) {
table. fncleartable ();
table. fnadddata (data. records);
}< BR >});
}
VaR _ tablecols = [{
Mdata: NULL,
Bsortable: false,
Sclass: "center ",
Swidth: "30 ",
Mrender: XXXX // function name
},{
Mdata: 'groupcode ',
Swidth: "120 ",
Bsortable: True
},{
Mdataprop: "UUID ",
Sclass: "center ",
Bsortable: false,
Swidth: "124 ",
Mrender: XXXX // function name
}];
Now let's look at the 1.10 statement.
$ (Document). Ready (function (){
VaR table, _ qdata;
Table = $ ('# example'). datatable ({
"Columns": _ tablecols,
"Createdrow": XXXXX, // function name
});
Loadlist ();
});
// table: Table object
function loadlist () {
$. ajax ({
URL: '/queryxx',
data: _ qdata,
datatype: 'json',
success: function (data) {
table. clear (). draw ();
table. rows. add (data. records ). draw ();
}< BR >});
}
VaR _ tablecols = [{
Data: NULL,
Orderable: false,
Classname: "center ",
Width: "30 ",
Render: XXXX // function name
},{
Data: 'groupcode ',
Width: "120 ",
Orderable: True
},{
Data: "UUID ",
Classname: "center ",
Orderable: false,
Width: "124 ",
Render: XXXX // function name
}];
We are looking at a 1.10 statement. In this case, place Ajax in the datatable.
VaR table = $ ('# example'). datatable ({
"Columns": _ tablecols, // _ tablecols.
Createdrow: XXXXX, // this function is used for row events
"Ajax ":{
"Url": "XXXXX ",
"Type": "Post ",
"Datasrc": function (JSON ){
Return JSON. records;
},
"Error": function (){
VaR DATA = {
"Data": []
};
Return data;
}
},});
This method can also assign values to the datatable ....
The use of mdataprop binding fields is the same as that of mdata, both of which are datatable 1.9 and earlier. Data is used after 1.10.
1.9 ----- "1.10
Mdata mdataprop --> data
Bsortable --> orderable
Sclass --> classname
Swidth --> width
Mrender --> render
Fncreatedrow --> createdrow
Datatables warning table ID requested unknown parameter from the data source for row
(Note: the reason for these warnings are normally due to null values in the data source. The key to suppressing this warning is through the use of the sdefaultcontent property .)
The following code can solve the problem:
1. "aocolumndefs ":[{
Sdefaultcontent :'',
Atargets: ['_ all']
}],
2.
Add$. FN. datatableext. serrmode = 'throw'
In the page where the plugin is used
Search datatable 1.10 Ajax
Difference between ableable1.9 and datatable1.10