zoukankan      html  css  js  c++  java
  • jqgrid 单列排序和组合排序

    有时,我们需要设置jqgrid表格按某个列排序,或则按多个列组合排序。如何实现?

    1)设置可以排序的列  sortable: true

    2)设置 multiSort: true 启用组合排序

        $("#jqGrid").jqGrid({
              ...
              colModel: [
                        { label: '<a href="HtmlPage1.html" title="测试标题">OrderID</a>', name: 'OrderID', key: true,  75,sortable: true },
                        { label: 'Order Date', name: 'OrderDate', editable: true,  150,sortable: true },
                        { label: 'Freight', name: 'Freight', editable: true,  150 }
    ] ... multiSort:
    true, //是否组合排序. true:组合排序 ... });

    注意事项:

    如果是用jqgrid自带的排序功能,则只能实现对当前页面的内容排序。

    而我们往往是需要将整个表格数据进行排序,这时需要用到服务端排序(即需要将排序的方式传递给服务端,服务端根据排序要求再次返回数据)

    后台端获取传入的排序字段:sidx、sord

    sidx:字段名,如果是组合排序则是前面字段排序加最后一个字段。  有点抽象,例子: id asc,name desc,code  最后字段为code

    sord:排序方式asc/desc

    string sidx = Request["sidx"];//排序条件
    string sord = Request["sord"];//最后个字段排序方式

    生成排序:

    sql = string.Format(@"select * from ({0}) order by {1}", sql, sidx+" "+sord);
  • 相关阅读:
    十大经典排序算法
    Redis 实现消息队列 MQ
    Memcache/Memcached的PHP操作手册(纯手稿版)
    PHP 共享内存使用与信号控制
    WebSocket和Socket的区别
    电商平台系统架构设计案例分析
    电商网站架构案例
    大型网站架构系列:电商网站架构案例
    电商峰值系统架构设计--转载
    IT系统
  • 原文地址:https://www.cnblogs.com/senyier/p/7326907.html
Copyright © 2011-2022 走看看