datagrid参数queryParams--easyUI

Html

         <div  region="center" border="false"  style="padding:0px 3px 0px 3px;margin:0px;"> 

              <table id="test"></table> 

    </div>


初置化gird

$(function(){ 

                   

                  loadgrid();    

                  //loadcombobox(null); 

       });

function loadgrid(){

       $('#test').datagrid({

              title:'任免信息列表',

              fit:true,

              nowrap: false,

              striped:false,

              //url:'rm.json',

              url:'http://127.0.0.1:8080/web/AppAndRemoveServer.server',

              queryParams:{},

              sortName: 'appandremove_id',

              sortOrder: 'asc',

              remoteSort: false,

              idField:'appandremove_id',

              frozenColumns:[[

                    {field:'ck',checkbox:true}

              ]],

              columns:[[{field:'appandremove_id',title:'任免批次编号',width:200,sortable:true},

              {field:'batch_name',title:'任免批次名称',width:240,sortable:true},

              {field:'batch_no',title:'任免批次编号',width:100,sortable:true},

              {field:'recorder_date',title:'登记时间',width:120,sortable:true},

              {field:'recorder_id',title:'登记人',width:100,sortable:true},

              {field:'state',title:'状态',width:100,sortable:true},

              {field:'memo',title:'备注',width:300}

          

              ]],

              pagination:true,

              pageNumber:1,

              pageSize:5,

              pageList:[5,10],           

              //singleSelect:true,

              rownumbers:true  

           });

    }

服务端接收rowspageordersort参数

    参数名称是easyui起的,值也是自动绑定

    可以在服务端通过request.getParameterNames();查看有什么参数

    接收参数值

    if(null!=request.getParameter("rows")) {              pageRows=Integer.parseInt(request.getParameter("rows").toString());  

       }  

       if(null!=request.getParameter("page")) {  

           page=Integer.parseInt(request.getParameter("page").toString());  

       } 

       if(null!=request.getParameter("order")) {  

           order=request.getParameter("order").toString();  

       }

       if(null!=request.getParameter("sort")) {  

           order=request.getParameter("sort").toString();  

         }

    然后拼装sql语句实现分页。

 增加查询参数,重新加载表格

function reloadgrid (stateVal)  {  

       //查询参数直接添加在url         

       /* var url =$('#test').datagrid('options').url;

        url = "http://127.0.0.1:8080/web/AppAndRemoveServer.server?state=" +stateVal;   

//重新赋值url 属性

        $('#test').datagrid('options').url=url;

        $("#test").datagrid('reload'); 

        */

        

        //查询参数直接添加在queryParams    

        var queryParams = $('#test').datagrid('options').queryParams;  

         queryParams.state = stateVal;  

         $('#test').datagrid('options').queryParams=queryParams;        

         $("#test").datagrid('reload'); 

        

    }

posted on 2011-01-25 09:26  archie2010  阅读(9182)  评论(0编辑  收藏  举报