Osort is an array of sort types, ' chinese-asc ' is the sort of a type that is defined by itself (*-ASC | | *-desc) name
The plugin should be sorted according to the type of content in the table (string, number, Chinese),
If you sort by Chinese type then use osort[' Chinese-asc ' and osort[' Chinese-desc '] method
Osort corresponding function inside the custom comparison method
jquery.fn.datatableext.osort[' chinese-asc ' = function (x, y) {
JavaScript comes with the Chinese comparison function, the specific use of self-access to understand
return X.localecompare (y);
};
jquery.fn.datatableext.osort[' chinese-desc ' = function (x, y) {
return Y.localecompare (x);
};
Atypes is an array of plug-in storage table content types
A regular expression of the Reg assignment to determine if it is a Chinese character
The return value is push to the atypes array, and the array is scanned when sorted, and ' Chinese ' calls the above two methods. Returns null default is ' string '
JQuery.fn.dataTableExt.aTypes.push (function (sData) {
var reg =/^[\u4e00-\u9fa5]{0,}$/;
if (Reg.test (SData)) {
Return ' Chinese ';
}
return null;
});
Front-end use is also the most important Oh ~ Method has is not how to use it is very headache ...
"Columndefs":
[
{"Atypes": "Chinese-asc", "atargets": [0]} refers to the 0th column of the table if the 0th column is Chinese
] So easy
Use DataTables to sort Chinese