easyui 列排序 java例子

来源:互联网 发布:淘宝网牛角梳 编辑:程序博客网 时间:2024/06/02 23:45

前端 jsp:

<div style="width:1000px;height:400px;padding-top: 50px"> 
    <table id="dg" title="My Dept" class="easyui-datagrid" style="width:1000px;height:400px" toolbar="#toolbar">
     <thead>
     <tr>
      <th field="tb" checkbox="true" align="center"></th>
      <th data-options="field:'name',width:150,align:'center',sortable:true">姓名</th>
      <th data-options="field:'job_name',width:150,align:'center',sortable:true">职位</th>
      <th data-options="field:'salary',width:150,align:'center',sortable:true">薪水</th>
      <th data-options="field:'start_date',width:150,align:'center',sortable:true">入职日期</th> 
      <th data-options="field:'levelName',width:150,align:'center',sortable:true">职位级别</th>
      <th data-options="field:'deptName',width:150,align:'center'">部门</th>
      
      </tr>
     </thead>
    </table>
    
    <div id="toolbar">
     <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">新增</a>
     <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">修改</a>
     <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">删除</a>
    </div>
   </div>

注意:easyui 排序自动向后台传两个参数值 

1、sort :  排序的列名

2、order: 排序的方式;desc 或是asc

后台接收参数:

接收的方式多种:

最常见: String   sort = request.getParameter("sort");

               String   sort = request.getParameter("sort");


后台sql(mybatis):

需要注意的是接收符号

<if test="order!=null and order!='' and sort!=null and sort!=''">


             <![CDATA[ORDER BY  ${sort} ${order}]]>


     </if>



1 0