jsp+layui表格排序

jsp+layui表格排序,不是排当前页面的,而是通过事件发送给后台。 

               table.render({ elem: '#prize_selector_table'
                , url:  '  ${ctx}/ds/company/dsCompanyInfo/queryPageData'
                , cellMinWidth: 80
                , toolbar: '#toolbarDemo' //开启头部工具栏,并为其绑定左侧模板
                , width: '95%'
                , id: 'prize_selector_table'
                , loading: true,
                autoSort:false,
          page:{    //layui的配置
          groups: 5 //只显示 1 个连续页码
          , first: false //不显示首页
          , last: false //不显示尾页
          , limits: [10, 20, 30]//页面显示多少数据
          },colos:[[{field: '排序的字段', title: '要排序的', width: 160  ,sort: true}]]})
        
          //这是方法 
          able.on('sort(test)', function(obj){ //注:tool是工具条事件名, lay-filter="对应的值"
          console.log(obj)
          console.log(obj.field)
          console.log(obj.type)
          console.log(this); //当前排序的 th 对象
            table.reload('prize_selector_table', {
              initSort: obj
              , where: {
                  field: obj.field //排序字段
                  ,type: obj.type //排序方式
                }
    });
//就是开启layui自带的排序,然后获取对应的值有asc,null,desc

 

 

 

posted @ 2020-11-10 17:36  GeKi  阅读(340)  评论(1)    收藏  举报