AI智能
改变未来

easyui 之datagrid分页

前端js

$(function(){
//初始化分页
loadList(\”\”);

});

function loadList(pcode){
var parm = $(\”#parm\”).serialize()
parm = decodeURIComponent(parm,true);
parm = encodeURI(encodeURI(parm));
//var $width = $(window).width();//(1)这样取值的话,结合(2)会导致在IE下列表出不来,故注释掉了
tree = $(’#wu-datagrid’).datagrid({
idField: ‘id’,
title : ‘’,
iconCls : ‘icon-ok’,
width : .width∗0.88,//(2)原来是这样的(.width*0.88, //(2)原来是这样的(.width∗0.88,//(2)原来是这样的(width0.88),会导致在IE下列表出不来,结合75行(1)的取值,这块应该写成’$.width0.88’
//loadFilter:pagerFilter, //数据加载
pageSize : 10,//默认选择的分页是每页5行数据
pageList : [ 5, 10, 15, 20 ],//可以选择的分页集合
nowrap : true,//设置为true,当数据长度超出列宽时将会自动截取
striped : true,//设置为true将交替显示行背景。
//collapsible : true,//显示可折叠按钮
toolbar:\”#wu-toolbar\”,//在添加 增添、删除、修改操作的按钮要用到这个
url:’<%=basePath%>yjsj/selectyjsj?’+parm,
//url调用Action方法
fit:true,
loadMsg : ‘数据装载中…’,
singleSelect:false,//为true时只能选择单行
fit:true,
//onClickRow:onClickRow,//定义单击行事件
fitColumns:true,//允许表格自动缩放,以适应父容器
//sortName : ‘xh’,//当数据表格初始化时以哪一列来排序
//sortOrder : ‘desc’,//定义排序顺序,可以是’asc’或者’desc’(正序或者倒序)。
remoteSort : false,
/*frozenColumns : [ [ {
field : ‘ck’
//checkbox : true
} ] ], */

pagination : true,//分页rownumbers : true ,//行数columns:[[{  field:\'id\',width:120,title:\'id\', align: \'center\', halign: \'center\',checkbox:true},{ field:\'bz\',width:130,title:\'备注\', align: \'center\', halign: \'center\',formatter:function(value){if(value!=null){ return \'<span title=\'+ value +\'>\'+value+\'</span>\'}else{return \'<span title=\'+ value +\'></span>\'}}},{ field:\'sfzt\',width:120,title:\'分发状态\', align: \'center\', halign: \'center\',formatter : function(value,row,index){if(value==\"0\"){return \'<a href=\"javascript:void(0)\" onclick=\"ffxq(\\\'\'+row.id+\'\\\',\\\'\'+row.xm+\'\\\')\">已分发</a>\'}else if(value==\"1\"){return \"未分发\"}}}]]});//行单击事件函数function onClickRow(){//获取点击选中的行var selectedRow = $(\'#wu-datagrid\').datagrid(\'getSelected\');//设置当点击行时选中该行对应的radio$(\"input[name=\'selectRadio\'][value=\'\"+selectedRow.code+\"\']\").attr(\'checked\',true);}

}

后台controller
try {

String page = req.getParameter(\"page\");String rows = req.getParameter(\"rows\");String hbh = req.getParameter(\"hbh\");String qfrq = req.getParameter(\"qfrq\");String xm = req.getParameter(\"xm\");String paramsTrans = new String(xm.getBytes(\"ISO-8859-1\"),\"UTF-8\");xm = java.net.URLDecoder.decode(paramsTrans , \"UTF-8\");String ywm = req.getParameter(\"ywm\");String zjhm1 = req.getParameter(\"zjh\");String sfzh = req.getParameter(\"sfzh\");String sfzt=req.getParameter(\"sfzt\");if(sfzt.equals(\"x\")){sfzt=\"\";}Map<String,String> map=new HashMap<String,String>();map.put(\"falg\", \"0\");map.put(\"page\", page);map.put(\"rows\", rows);map.put(\"hbh\", hbh);map.put(\"qfrq\", qfrq);map.put(\"xm\", xm);map.put(\"ywm\", ywm);map.put(\"zjhm1\", zjhm1);map.put(\"sfzh\", sfzh);map.put(\"status\", \"0\");map.put(\"sfzt\", sfzt);PageInfo<Map<String,String>> l=yjsjService.selectyjsj(map);JSONObject json = new JSONObject();json.put(\"total\", l.getTotal()+\"\");json.put(\"rows\", l.getList());reqs.getWriter().append(json.toString()).flush();} catch (Exception e) {e.printStackTrace();}

实现类
@Override
public PageInfo<Map<String,String>> selectyjsj(Map<String, String> map) {

int _page = 0;int _rows = 0;try {_page = Integer.parseInt(map.get(\"page\"));} catch (Exception e) {_page = 0;}try {_rows = Integer.parseInt(map.get(\"rows\"));} catch (Exception e) {_rows = 10;}PageMethod.startPage(_page, _rows);List<Map<String, String>> list = yjsjDao.selectyjsj(map);return new PageInfo<Map<String, String>>(list);}
赞(0) 打赏
未经允许不得转载:爱站程序员基地 » easyui 之datagrid分页