jquery table 插件排序
2015-12-27 21:58
801 查看
http://cdn.datatables.net/plug-ins/1.10.10/sorting/
这是所有排序插件
http://datatables.net/plug-ins/sorting/
这是用法
IP地址的改良了一下
* @example
* $('#example').dataTable( {
* columnDefs: [
{ orderable:false,//禁用排序
targets:[0] //指定的列
},
* { type: 'ip-address', targets: 0 }
* ],
"order": [[ 1, "asc" ]], 默认排序
* } );
*/
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"ip-address-pre": function ( a ) {
a = a.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)[0];
var i, item;
var m = a.split("."),
n = a.split(":"),
x = "",
xa = "";
if (m.length == 4) {
// IPV4
for(i = 0; i < m.length; i++) {
item = m[i];
if(item.length == 1) {
x += "00" + item;
}
else if(item.length == 2) {
x += "0" + item;
}
else {
x += item;
}
}
}
else if (n.length > 0) {
// IPV6
var count = 0;
for(i = 0; i < n.length; i++) {
item = n[i];
if (i > 0) {
xa += ":";
}
if(item.length === 0) {
count += 0;
}
else if(item.length == 1) {
xa += "000" + item;
count += 4;
}
else if(item.length == 2) {
xa += "00" + item;
count += 4;
}
else if(item.length == 3) {
xa += "0" + item;
count += 4;
}
else {
xa += item;
count += 4;
}
}
// Padding the ::
n = xa.split(":");
var paddDone = 0;
for (i = 0; i < n.length; i++) {
item = n[i];
if (item.length === 0 && paddDone === 0) {
for (var padding = 0 ; padding < (32-count) ; padding++) {
x += "0";
paddDone = 1;
}
}
else {
x += item;
}
}
}
return x;
},
"ip-address-asc": function ( a, b ) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"ip-address-desc": function ( a, b ) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
});
这是所有排序插件
http://datatables.net/plug-ins/sorting/
这是用法
IP地址的改良了一下
* @example
* $('#example').dataTable( {
* columnDefs: [
{ orderable:false,//禁用排序
targets:[0] //指定的列
},
* { type: 'ip-address', targets: 0 }
* ],
"order": [[ 1, "asc" ]], 默认排序
* } );
*/
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
"ip-address-pre": function ( a ) {
a = a.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/)[0];
var i, item;
var m = a.split("."),
n = a.split(":"),
x = "",
xa = "";
if (m.length == 4) {
// IPV4
for(i = 0; i < m.length; i++) {
item = m[i];
if(item.length == 1) {
x += "00" + item;
}
else if(item.length == 2) {
x += "0" + item;
}
else {
x += item;
}
}
}
else if (n.length > 0) {
// IPV6
var count = 0;
for(i = 0; i < n.length; i++) {
item = n[i];
if (i > 0) {
xa += ":";
}
if(item.length === 0) {
count += 0;
}
else if(item.length == 1) {
xa += "000" + item;
count += 4;
}
else if(item.length == 2) {
xa += "00" + item;
count += 4;
}
else if(item.length == 3) {
xa += "0" + item;
count += 4;
}
else {
xa += item;
count += 4;
}
}
// Padding the ::
n = xa.split(":");
var paddDone = 0;
for (i = 0; i < n.length; i++) {
item = n[i];
if (item.length === 0 && paddDone === 0) {
for (var padding = 0 ; padding < (32-count) ; padding++) {
x += "0";
paddDone = 1;
}
}
else {
x += item;
}
}
}
return x;
},
"ip-address-asc": function ( a, b ) {
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
},
"ip-address-desc": function ( a, b ) {
return ((a < b) ? 1 : ((a > b) ? -1 : 0));
}
});
相关文章推荐
- jQuery的选择器中的通配符
- 学习 jquery easyui 的网站
- Jquery与Dom对象互相转换
- jQuery自动完成插件autocompleter 使用注意事项
- Jquery easyui开启行编辑模式增删改操作
- jQuery的补充知识(动画和AJAX)
- jQuery
- jQuery $.each用法
- jQuery实现全选、全不选、反选
- jQuery获取循环中的选中单选按钮radio的值
- 《jQuery基础教程》第四版第七章课后练习——使用插件
- jquery自动刷新页面的几种方法
- 全屏滚动-jQuery插件实现
- jquery中的选择器01
- jQuery 和 json 简单例子(注意callback函数的处理!!) (servlet返回json,jquery更新,java json)
- jQuery实现下拉菜单
- jQuery实现下拉菜单
- 【东臣PHP】JQuery+Ajax
- 【嘉兴东臣php】jquery
- 【嘉兴东臣PHP】 闭包+JQuery