1.在页面需要的地方加上如下代码:
<input id="userId" name="userId" type="hidden" style="width: 150px" class="inputxt" ignore="ignore"/> <input name="userName" class="inputxt" value="" id="userName" readonly="readonly" datatype="*"/>
<t:choose width="800" height="600" hiddenName="userId" hiddenid="id" url="apiUserController.do?users" name="userList" icon="icon-search" title="选择操作标签" textname="userName" isclear="true" isInit="true"></t:choose>2.userId是需要传入后台的,userName是页面展示的,<t:choose>标签的url指向后台跳转,textname---显示的文本(字段),isclear清除-重置按钮
3.后台方法
@RequestMapping(params = "users") public ModelAndView users(HttpServletRequest request) { ModelAndView mv = new ModelAndView("com/jeecg/api_user/usersSelect"); String ids = oConvertUtils.getString(request.getParameter("ids")); mv.addObject("ids", ids); return mv; }4.前台页面
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@include file="/context/mytags.jsp"%> <!DOCTYPE html > <html> <head> <title>用户集合</title> <t:base type="jquery,easyui,tools"></t:base> </head> <body style="overflow-y: hidden" scroll="no"> <t:datagrid pagination="false" name="userList" title="用户选择" actionUrl="apiUserController.do?datagrid" idField="id" checkbox="false" showRefresh="false" fit="true" queryMode="group" onLoadSuccess="initCheck"> <t:dgCol title="common.id" field="id" hidden="true"></t:dgCol> <t:dgCol title="用户名" field="userName" width="50" query="true" ></t:dgCol> <t:dgCol title="手机" field="phone" query="true" queryMode="single" width="120"></t:dgCol> <t:dgCol title="头像" field="userImg" queryMode="single" width="250" image="true" imageSize="50,50" ></t:dgCol> <t:dgCol title="简介" field="info" queryMode="single" width="120"></t:dgCol> <t:dgCol title="用户角色" field="role" query="true" queryMode="single" dictionary="role_t" width="120"></t:dgCol> <t:dgCol title="称号" field="sign" query="true" queryMode="single" width="120"></t:dgCol> </t:datagrid> </body> </html> <script type="text/javascript"> function initCheck(data){ var ids = "${ids}"; var idArr = ids.split(","); for(var i=0;i<idArr.length;i++){ if(idArr[i]!=""){ $("#userList").datagrid("selectRecord",idArr[i]); } } } </script>