在JEECG程序中,设计到的公共方法存放在webRoot/plug-in/tools/curdtools.js中,初学者容易找不到!
如:页面为:webpage/jeecg/demo/jeecgDemo/jeecgDemoList.jsp
- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
- <%@include file="/context/mytags.jsp"%>
- <div class="easyui-layout" fit="true">
- <div region="center" style="padding:1px;">
- <%-- update-begin--Author:tanghan Date:20130713 for添加checkbox--%>
- <t:datagrid name="jeecgDemoList" title="DEMO示例列表" autoLoadData="true" actionUrl="jeecgDemoController.do?datagrid" sortName="userName" fitColumns="true" idField="id" fit="true" queryMode="group" checkbox="true" >
- <%-- update-end--Author:tanghan Date:20130713 for添加checkbox--%>
- <t:dgCol title="编号" field="id" hidden="false"></t:dgCol>
- <t:dgCol title="用户名" field="userName" query="true" frozenColumn="true" ></t:dgCol>
- <t:dgCol title="电话号码" sortable="false" field="mobilePhone" query="true"></t:dgCol>
- <t:dgCol title="办公电话" field="officePhone" query="true"></t:dgCol>
- <t:dgCol title="创建日期" field="createTime" formatter="yyyy-MM-dd hh:mm:ss" query="true" queryMode="group"></t:dgCol>
- <t:dgCol title="邮箱" field="email" query="true"></t:dgCol>
- <t:dgCol title="年龄" sortable="true" field="age" query="true"></t:dgCol>
- <t:dgCol title="工资" field="salary" query="true"></t:dgCol>
- <t:dgCol title="生日" field="birthday" formatter="yyyy/MM/dd" query="true"></t:dgCol>
- <t:dgCol title="性别" sortable="true" field="sex" dictionary="sex" query="true" ></t:dgCol>
- <t:dgCol title="状态" field="status" query="true" replace="未处理_0,已处理_1"></t:dgCol>
- <t:dgCol title="操作" field="opt" width="80"></t:dgCol>
- <t:dgFunOpt exp="status#eq#0" operationCode="szqm" funname="szqm(id)" title="审核" />
- <t:dgDelOpt operationCode="del" title="删除" url="jeecgDemoController.do?del&id={id}" />
- <t:dgToolBar operationCode="add" title="录入" icon="icon-add" url="jeecgDemoController.do?addorupdate" funname="<span style="color:#ff0000;">add</span>"></t:dgToolBar>
- <t:dgToolBar operationCode="edit" title="编辑" icon="icon-edit" url="jeecgDemoController.do?addorupdate" funname="<span style="color:#ff0000;">update</span>"></t:dgToolBar>
- <t:dgToolBar operationCode="detail" title="查看" icon="icon-search" url="jeecgDemoController.do?addorupdate" funname="<span style="color:#ff0000;">detail</span>"></t:dgToolBar>
- <%-- update-begin--Author:tanghan Date:20130713 for添加全选方法--%>
- <t:dgToolBar title="批量删除" icon="icon-remove" url="jeecgDemoController.do?doDeleteALLSelect" funname="<span style="color:#ff0000;">deleteALLSelect</span>"></t:dgToolBar>
- <%-- update-end--Author:tanghan Date:20130713 for添加全选方法--%>
- </t:datagrid>
- </div>
- </div>
- <script type="text/javascript">
- function szqm(id) {
- createwindow('审核', 'jeecgDemoController.do?doCheck&id=' + id);
- }
- $(document).ready(function(){
- $("input[name='createTime_begin']").attr("class","easyui-datebox");
- $("input[name='createTime_end']").attr("class","easyui-datebox");
- });
- </script>
以上标红的Js方法在webRoot/plug-in/tools/curdtools.js中都有对应:
- /**
- * 添加事件打开窗口
- * @param title 编辑框标题
- * @param addurl//目标页面地址
- */
- function <span style="color:#ff0000;">add</span>(title,addurl,gname,width,height) {
- gridname=gname;
- createwindow(title, addurl,width,height);
- }
- /**
- * 更新事件打开窗口
- * @param title 编辑框标题
- * @param addurl//目标页面地址
- * @param id//主键字段
- */
- function <span style="color:#ff0000;">update</span>(title,url, id,width,height) {
- gridname=id;
- var rowsData = $('#'+id).datagrid('getSelections');
- if (!rowsData || rowsData.length==0) {
- tip('请选择编辑项目');
- return;
- }
- if (rowsData.length>1) {
- tip('请选择一条记录再编辑');
- return;
- }
- url += '&id='+rowsData[0].id;
- createwindow(title,url,width,height);
- }
- /**
- * 查看详细事件打开窗口
- * @param title 查看框标题
- * @param addurl//目标页面地址
- * @param id//主键字段
- */
- function <span style="color:#ff0000;">detail</span>(title,url, id,width,height) {
- var rowsData = $('#'+id).datagrid('getSelections');
- // if (rowData.id == '') {
- // tip('请选择查看项目');
- // return;
- // }
- if (!rowsData || rowsData.length == 0) {
- tip('请选择查看项目');
- return;
- }
- if (rowsData.length > 1) {
- tip('请选择一条记录再查看');
- return;
- }
- url += '&load=detail&id='+rowsData[0].id;
- createdetailwindow(title,url,width,height);
- }
- /**
- * 多记录刪除請求
- * @param title
- * @param url
- * @param gname
- * @return
- */
- function <span style="color:#ff0000;">deleteALLSelect</span>(title,url,gname) {
- gridname=gname;
- var ids = [];
- var rows = $("#"+gname).datagrid('getSelections');
- if (rows.length > 0) {
- $.dialog.confirm('你确定永久删除该数据吗?', function(r) {
- if (r) {
- for ( var i = 0; i < rows.length; i++) {
- ids.push(rows[i].id);
- }
- $.ajax({
- url : url,
- type : 'post',
- data : {
- ids : ids.join(',')
- },
- cache : false,
- success : function(data) {
- var d = $.parseJSON(data);
- if (d.success) {
- var msg = d.msg;
- tip(msg);
- reloadTable();
- $("#"+gname).datagrid('unselectAll');
- ids='';
- }
- }
- });
- }
- });
- } else {
- tip("请选择需要删除的数据");
- }
- }