$(".datagrid-cell").click(function () { var sort = $(this).parent("td").attr("field"); var fileter = "TaskID,CarNum"; //过滤此字段不进行排序 if (fileter.indexOf(sort)>=0) { return false; }; data = ""; var isHave = false; var ascordesc = "asc"; for (var i = 0; i < orderby.length; i++) { if (orderby[i].sort == sort) { if (orderby[i].order == "desc") { ascordesc = orderby[i].order = "asc" } else if (orderby[i].order == "asc") { ascordesc = orderby[i].order = "desc" } isHave = true; break; } } //如果不存在..... if (!isHave) { orderby.push(new comefrom(sort, ascordesc)); } var ficon = $(this).find(".datagrid-sort-icon"); ficon.css("background", "url(\"images/datagrid_sort_" + ascordesc + ".gif\") no-repeat center"); ficon.css("padding", "2px 13px 3px 0px"); $(this).addClass("datagrid-sort-" + ascordesc + ""); for (var i = 0; i < orderby.length; i++) { data += orderby[i].sort + "," + orderby[i].order + "|"; } data = data.substr(0, data.length - 1); Search(); });
连接地址:http://blog.csdn.net/loveyang7733/article/details/7102838
这个不行的
@love begins coding:
http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx
$('#tt').datagrid({
title:'Sortable Column',
width:550,
height:250,
url:'/demo4/data/getItems',
columns:[[
{field:'itemid',title:'Item ID',width:80,sortable:true},
{field:'productid',title:'Product ID',width:80,sortable:true},
{field:'listprice',title:'List Price',width:80,align:'right',sortable:true},
{field:'unitcost',title:'Unit Cost',width:80,align:'right',sortable:true},
{field:'attr1',title:'Attribute',width:100},
{field:'status',title:'Status',width:60}
]],
pagination:true,
sortName:'itemid',
sortOrder:'asc'
});
@荒野的呼唤: 大哥 麻烦看清李牧 我要的是排序的例子
@love begins coding:
$('#tt').datagrid({
title:'Sortable Column',
width:550,
height:250,
url:'/demo4/data/getItems',
columns:[[
{field:'itemid',title:'Item ID',width:80,sortable:true},
{field:'productid',title:'Product ID',width:80,sortable:true},
{field:'listprice',title:'List Price',width:80,align:'right',sortable:true},
{field:'unitcost',title:'Unit Cost',width:80,align:'right',sortable:true},
{field:'attr1',title:'Attribute',width:100},
{field:'status',title:'Status',width:60}
]],
pagination:true,
sortName:'itemid',
sortOrder:'asc'
});
这些不就是排序吗,上面连接里面排序,分页都有啊。