首页 新闻 搜索 专区 学院

asp.net 如何结合easyui datagrid实现排序?

0
悬赏园豆:100 [待解决问题]

asp.net 如何结合easyui datagrid实现排序?最好能给个详细的例子,谢谢

love begins coding的主页 love begins coding | 初学一级 | 园豆:11
提问于:2012-05-02 13:02
< >
分享
所有回答(1)
0
 $(".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

悟行 | 园豆:12429 (专家六级) | 2012-05-02 13:25

这个不行的

支持(0) 反对(0) love begins coding | 园豆:11 (初学一级) | 2012-05-02 13:26

@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'

});

支持(0) 反对(0) 悟行 | 园豆:12429 (专家六级) | 2012-05-02 13:34

@荒野的呼唤: 大哥 麻烦看清李牧  我要的是排序的例子

支持(0) 反对(0) love begins coding | 园豆:11 (初学一级) | 2012-05-02 13:41

@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'

});

这些不就是排序吗,上面连接里面排序,分页都有啊。

支持(0) 反对(0) 悟行 | 园豆:12429 (专家六级) | 2012-05-02 13:44
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册