e73af3ae98413b36771c9b793f799c3600fb4b62.svn-base 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <%@page language="java" pageEncoding="UTF-8"%>
  2. <%
  3. String path = request.getContextPath();
  4. %>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9. <title>基本表格模板</title>
  10. <!--框架必需start-->
  11. <script type="text/javascript" src="<%=path%>/libs/js/jquery.js"></script>
  12. <script type="text/javascript" src="<%=path%>/libs/js/language/cn.js"></script>
  13. <script type="text/javascript" src="<%=path%>/libs/js/framework.js"></script>
  14. <link href="<%=path%>/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  15. <link rel="stylesheet" type="text/css" id="skin" prePath="<%=path%>/" scrollerY="false"/>
  16. <link rel="stylesheet" type="text/css" id="customSkin"/>
  17. <!--框架必需end-->
  18. <!--数据表格start-->
  19. <script src="<%=path%>/libs/js/table/quiGrid.js" type="text/javascript"></script>
  20. <!--数据表格end-->
  21. <!--自动提示框start-->
  22. <script type='text/javascript' src='<%=path%>/libs/js/form/suggestion.js'></script>
  23. <!--自动提示框end-->
  24. <!-- 组合下拉框start -->
  25. <script type="text/javascript" src="<%=path%>/libs/js/form/selectCustom.js"></script>
  26. <!-- 组合拉框end -->
  27. <!-- 条件过滤器 start -->
  28. <script type="text/javascript" src="<%=path%>/libs/js/form/filter.js"></script>
  29. <!-- 条件过滤器 end -->
  30. <!-- 双向选择器start -->
  31. <script type="text/javascript" src="<%=path%>/libs/js/form/lister.js"></script>
  32. <!-- 双向选择器end -->
  33. <!-- 树组件start -->
  34. <script type="text/javascript" src="<%=path%>/libs/js/tree/ztree/ztree.js"></script>
  35. <link type="text/css" rel="stylesheet" href="<%=path%>/libs/js/tree/ztree/ztree.css"></link>
  36. <!-- 树组件end -->
  37. <!-- 树形双选器start -->
  38. <script type="text/javascript" src="<%=path%>/libs/js/form/listerTree.js"></script>
  39. <!-- 树形双选器end -->
  40. </head>
  41. <body>
  42. <div class="intro">
  43. 这里展示了自动提示框作为编辑器,过滤器、双选器、表格等与组合下拉框构造成编辑器。为简化代码,编辑结果并未提交到后台。
  44. </div>
  45. <div class="padding_right5">
  46. <div id="maingrid"></div>
  47. </div>
  48. <script type="text/javascript">
  49. var g;
  50. var gridEditorColumns=[
  51. { display: '姓名', name: 'userName', align: 'center', width: "30%"},
  52. { display: '性别', name: 'userSex', align: 'center' , width: "20%"},
  53. { display: '部门', name: 'orgName', align: 'center' , width: "30%"},
  54. { display: '学历', name: 'userEducation', align: 'center', width: "20%" }
  55. ]
  56. var gridEditorColumns2=[
  57. { display: '姓名', name: 'userName', align: 'center', width: 150},
  58. { display: '性别', name: 'userSex', align: 'center' , width: 80}
  59. ]
  60. var gridTreeEditorColumns=[
  61. { display: '部门名', name: 'name', id:'deptId', width: 150, align: 'left' },
  62. { display: '部门id', name: 'id',width: 80, type: 'int', align: 'left' }
  63. ]
  64. var filterData={"list":[
  65. {"name":"部门1","list":[
  66. {"key":"员工1","value":"1","iconClass":"icon_user"},
  67. {"key":"员工2","value":"2","iconClass":"icon_user"},
  68. {"key":"员工3","value":"3","iconClass":"icon_user_female"},
  69. {"key":"员工4","value":"4","iconClass":"icon_user"},
  70. {"key":"员工5","value":"5","iconClass":"icon_user"}]},
  71. {"name":"部门2","list":[
  72. {"key":"员工6","value":"6","iconClass":"icon_user_female"},
  73. {"key":"员工7","value":"7","iconClass":"icon_user"},
  74. {"key":"员工8","value":"8","iconClass":"icon_user_worker"}]},
  75. {"name":"部门3","list":[
  76. {"key":"员工9","value":"9","iconClass":"icon_user"},
  77. {"key":"员工10","value":"10","iconClass":"icon_user"},
  78. {"key":"员工11","value":"11","iconClass":"icon_user"},
  79. {"key":"员工12","value":"12","iconClass":"icon_user"},
  80. {"key":"员工13","value":"13","iconClass":"icon_user"}]},
  81. {"name":"部门4","list":[
  82. {"key":"员工14","value":"14","iconClass":"icon_user"},
  83. {"key":"员工15","value":"15","iconClass":"icon_user"},
  84. {"key":"员工16","value":"16","iconClass":"icon_user"}]}]}
  85. var gridTreeEditorData={"rows":[
  86. {"id":1,"parentId":0,"name":"南京分公司","iconClass":"icon_star","open":false,"children":[
  87. {"id":2,"parentId":1,"name":"市场部","iconClass":"icon_list","open":false,"children":[
  88. {"id":3,"parentId":2,"name":"市场1组","iconClass":"icon_mark","children":null},
  89. {"id":11,"parentId":2,"name":"市场2组","iconClass":"icon_mark","children":null},
  90. {"id":12,"parentId":2,"name":"市场3组","iconClass":"icon_mark","children":null}
  91. ]},
  92. {"id":13,"parentId":1,"name":"财务部","iconClass":"icon_list","children":null},
  93. {"id":14,"parentId":1,"name":"行政部","iconClass":"icon_list","children":null},
  94. {"id":15,"parentId":1,"name":"工程部","iconClass":"icon_list","children":null},
  95. {"id":16,"parentId":1,"name":"技术部","iconClass":"icon_list","children":null},
  96. {"id":17,"parentId":1,"name":"生产部","iconClass":"icon_list","children":null}
  97. ]},
  98. {"id":7,"parentId":0,"name":"杭州办事处","iconClass":"icon_star","open":false,"children":[
  99. {"id":8,"parentId":7,"name":"接待处","iconClass":"icon_list","children":null},
  100. {"id":9,"parentId":7,"name":"洽谈处","iconClass":"icon_list","children":null}
  101. ]},
  102. {"id":18,"parentId":0,"name":"郑州办事处","iconClass":"icon_star","open":false,"children":[
  103. {"id":19,"parentId":18,"name":"接待处","iconClass":"icon_list","children":null},
  104. {"id":20,"parentId":18,"name":"洽谈处","iconClass":"icon_list","children":null}
  105. ]},
  106. {"id":21,"parentId":0,"name":"苏州办事处","iconClass":"icon_star","open":false,"children":[
  107. {"id":22,"parentId":21,"name":"接待处","iconClass":"icon_list","children":null},
  108. {"id":23,"parentId":21,"name":"洽谈处","iconClass":"icon_list","children":null}
  109. ]},
  110. {"id":24,"parentId":0,"name":"北京办事处","iconClass":"icon_star","children":null}
  111. ]}
  112. var listerData={fromList:[{value:"1",key:"员工1"},{value:"2",key:"员工2"},{value:"3",key:"员工3"},{value:"4",key:"员工4"}],"toList":[]};
  113. var listerDataFormat=[];
  114. var listerTreeData={"toList":[],"fromList":[
  115. {"id":"1","parentId":"0","open":"true","name":"部门1","oldParentId":"null","drag":"false"},
  116. {"id":"11","parentId":"1","name":"员工1","oldParentId":"1"},
  117. {"id":"12","parentId":"1","name":"员工2","oldParentId":"1"},
  118. {"id":"13","parentId":"1","name":"员工3","oldParentId":"1"},
  119. {"id":"2","parentId":"0","open":"true","name":"部门2","oldParentId":"null","drag":"false"},
  120. {"id":"21","parentId":"2","name":"员工4","oldParentId":"2"}
  121. ]}
  122. var listerTreeDataFormat=[];
  123. var listdata={"list":[
  124. {value:"1",key:"北京",suggest:"北京|beijing|bj"},
  125. {value:"2",key:"广州",suggest:"广州|guangzhou|gz"},
  126. {value:"3",key:"深圳",suggest:"深圳|shenzhen|sz"},
  127. {value:"4",key:"上海",suggest:"上海|shanghai|sh"},
  128. {value:"5",key:"长沙",suggest:"长沙|changsha|cs"},
  129. {value:"6",key:"成都",suggest:"成都|chengdu|cd"},
  130. {value:"7",key:"贵阳",suggest:"贵阳|guiyang|gy"},
  131. {value:"8",key:"海口",suggest:"海口|haikou|hk"},
  132. {value:"9",key:"杭州",suggest:"杭州|hangzhou|hz"},
  133. {value:"10",key:"昆明",suggest:"昆明|kunming|km"},
  134. {value:"11",key:"南昌",suggest:"南昌|nanchang|nc"},
  135. {value:"12",key:"南京",suggest:"南京|nanjing|nj"},
  136. {value:"13",key:"三亚",suggest:"三亚|sanya|sy"},
  137. {value:"14",key:"沈阳",suggest:"沈阳|shenyang|sy"},
  138. {value:"15",key:"温州",suggest:"温州|wenzhou|wz"},
  139. {value:"16",key:"武汉",suggest:"武汉|wuhan|wh"},
  140. {value:"17",key:"厦门",suggest:"厦门|xiamen|xm"},
  141. {value:"18",key:"西安",suggest:"西安|xian|xa"},
  142. {value:"19",key:"郑州",suggest:"郑州|zhenghou|zz"},
  143. {value:"20",key:"汕头",suggest:"汕头|shantou|st"},
  144. {value:"21",key:"太原",suggest:"太原|taiyuan|ty"},
  145. {value:"22",key:"天津",suggest:"天津|tianjin|tj"}]};
  146. var gridEditorData;
  147. var gridTreeEditorDataFarmat=[];
  148. function initComplete(){
  149. $(".intro").bind("click",function(e){
  150. g.endEdit();
  151. })
  152. $.post("<%=path%>/getUsersOfPager.action",
  153. {},
  154. function(result){
  155. gridEditorData = result;
  156. initGrid();
  157. },"json");
  158. gridTreeEditorDataFarmat=formatTreeData(gridTreeEditorData["rows"]);
  159. for (var rowparm in listerData["fromList"])
  160. {
  161. var item = listerData["fromList"][rowparm];
  162. if (!item) continue;
  163. listerDataFormat.push(item);
  164. }
  165. for (var rowparm2 in listerTreeData["fromList"])
  166. {
  167. var item2 = listerTreeData["fromList"][rowparm2];
  168. if (!item2) continue;
  169. listerTreeDataFormat.push(item2);
  170. }
  171. }
  172. var newData=[];
  173. function formatTreeData(data){
  174. for (var rowparm in data)
  175. {
  176. var item = data[rowparm];
  177. if (!item) continue;
  178. newData.push(item);
  179. if(item["children"]){
  180. formatTreeData(item["children"]);
  181. }
  182. }
  183. return newData;
  184. }
  185. function initGrid(){
  186. g = $("#maingrid").quiGrid({
  187. columns: [
  188. { display: '姓名', name: 'userName', align: 'left', width: 80,editor: { type: 'text',maxlength:5,tip:'不超过5个字的中文' }},
  189. { display: '组合下拉框-过滤器', name: 'child', showTitle:true, align: 'left', width: 155,editor: { type: 'selectCustom',boxWidth:500,selWidth:150,multiMode:true,data:filterData,child:{type:'filter',multiMode:true,groupMode:true}},render:function (item){
  190. if(!item.child){
  191. return "";
  192. }
  193. var itemArray=item.child.split(",");
  194. var childStr="";
  195. for (var i = 0; i < itemArray.length; i++){
  196. for (var j = 0; j < filterData["list"].length; j++){
  197. for (var k = 0; k < filterData["list"][j]["list"].length; k++){
  198. var item= filterData["list"][j]["list"][k];
  199. if (item['value'] == itemArray[i]){
  200. childStr=childStr+item['key']+",";
  201. continue;
  202. }
  203. }
  204. }
  205. }
  206. if (childStr.length > 0 ){
  207. childStr = childStr.substring(0, childStr.length-1);
  208. }
  209. return childStr;
  210. }},
  211. { display: '组合下拉框-表格多选', name: 'child2', showTitle:true, align: 'left', width: 155,editor:
  212. { type: 'selectCustom',boxWidth:500,selWidth:150,multiMode:true,data:gridEditorData,child:
  213. {type:'grid',columns:gridEditorColumns,pageSize:5,rownumbers:true,checkbox:true,percentWidthMode:true,height:300,width:500,valueField:"userId",labelField:"userName",
  214. showPageInfo:false,selectRowButtonOnly:false,isChecked:checkedHandlerEditor,onCheckRow: checkRowHandlerEditor, onCheckAllRow: checkAllRowHandlerEditor}},
  215. render:function (item){
  216. if(!item.child2){
  217. return "";
  218. }
  219. var itemArray=item.child2.split(",");
  220. var childStr="";
  221. for (var i = 0; i < itemArray.length; i++){
  222. for (var j = 0; j < gridEditorData["rows"].length; j++){
  223. if (gridEditorData["rows"][j]['userId'] == itemArray[i]){
  224. childStr=childStr+gridEditorData["rows"][j]['userName']+",";
  225. continue;
  226. }
  227. }
  228. }
  229. if (childStr.length > 0 ){
  230. childStr = childStr.substring(0, childStr.length-1);
  231. }
  232. return childStr;
  233. }},
  234. { display: '组合下拉框-树表格多选', name: 'child3', showTitle:true, align: 'left', width: 155,editor:
  235. { type: 'selectCustom',boxWidth:300,selWidth:150,multiMode:true,data:gridTreeEditorData,child:
  236. {type:'grid',columns:gridTreeEditorColumns,checkbox:true,rownumbers:false,usePager:false,width:300,valueField:"id",labelField:"name",
  237. autoCheckChildren:false,selectRowButtonOnly:false,tree:{ columnId: 'deptId' },isChecked:checkedHandlerEditor,onCheckRow: checkRowHandlerEditor, onCheckAllRow: checkAllRowHandlerEditor}},
  238. render:function (item){
  239. if(!item.child3){
  240. return "";
  241. }
  242. var itemArray=item.child3.split(",");
  243. var childStr="";
  244. for (var i = 0; i < itemArray.length; i++){
  245. for (var j = 0; j < gridTreeEditorDataFarmat.length; j++){
  246. if (gridTreeEditorDataFarmat[j]['id'] == itemArray[i]){
  247. childStr=childStr+gridTreeEditorDataFarmat[j]['name']+",";
  248. continue;
  249. }
  250. }
  251. }
  252. if (childStr.length > 0 ){
  253. childStr = childStr.substring(0, childStr.length-1);
  254. }
  255. return childStr;
  256. }},
  257. { display: '组合下拉框-表格单选', name: 'child4', align: 'left', width: 155,editor:
  258. { type: 'selectCustom',boxWidth:280,selWidth:150,data:gridEditorData,child:
  259. {type:'grid',columns:gridEditorColumns2,pageSize:5,rownumbers:true,checkbox:false,percentWidthMode:true,height:300,width:280,valueField:"userId",labelField:"userName",
  260. showPageInfo:false,selectRowButtonOnly:false}},
  261. render:function (item){
  262. if(!item.child4){
  263. return "";
  264. }
  265. var itemArray=item.child4.split(",");
  266. var childStr="";
  267. for (var i = 0; i < itemArray.length; i++){
  268. for (var j = 0; j < gridEditorData["rows"].length; j++){
  269. if (gridEditorData["rows"][j]['userId'] == itemArray[i]){
  270. childStr=childStr+gridEditorData["rows"][j]['userName']+",";
  271. continue;
  272. }
  273. }
  274. }
  275. if (childStr.length > 0 ){
  276. childStr = childStr.substring(0, childStr.length-1);
  277. }
  278. return childStr;
  279. }},
  280. { display: '组合下拉框-树表格单选', name: 'child5', align: 'left', width: 155,editor:
  281. { type: 'selectCustom',boxWidth:300,selWidth:150,data:gridTreeEditorData,child:
  282. {type:'grid',columns:gridTreeEditorColumns,pageSize:5,rownumbers:true,checkbox:false,percentWidthMode:true,height:300,valueField:"id",labelField:"name",
  283. showPageInfo:false,selectRowButtonOnly:false,tree:{ columnId: 'deptId' }}},
  284. render:function (item){
  285. if(!item.child5){
  286. return "";
  287. }
  288. var itemArray=item.child5.split(",");
  289. var childStr="";
  290. for (var i = 0; i < itemArray.length; i++){
  291. for (var j = 0; j < gridTreeEditorDataFarmat.length; j++){
  292. if (gridTreeEditorDataFarmat[j]['id'] == itemArray[i]){
  293. childStr=childStr+gridTreeEditorDataFarmat[j]['name']+",";
  294. continue;
  295. }
  296. }
  297. }
  298. if (childStr.length > 0 ){
  299. childStr = childStr.substring(0, childStr.length-1);
  300. }
  301. return childStr;
  302. }},
  303. { display: '组合下拉框-双向选择器', name: 'child6', showTitle:true, align: 'left', width: 155,editor:
  304. { type: 'selectCustom',boxWidth:280,selWidth:150,multiMode:true, data:listerData,child:
  305. {type:'lister',listerWidth:105,listerHeight:120}},
  306. render:function (item){
  307. if(!item.child6){
  308. return "";
  309. }
  310. var itemArray=item.child6.split(",");
  311. var childStr="";
  312. for (var i = 0; i < itemArray.length; i++){
  313. for (var j = 0; j < listerDataFormat.length; j++){
  314. if (listerDataFormat[j]['value'] == itemArray[i]){
  315. childStr=childStr+listerDataFormat[j]['key']+",";
  316. continue;
  317. }
  318. }
  319. }
  320. if (childStr.length > 0 ){
  321. childStr = childStr.substring(0, childStr.length-1);
  322. }
  323. return childStr;
  324. }},
  325. { display: '组合下拉框-树形双选器', name: 'child7', showTitle:true, align: 'left', width: 155,editor:
  326. { type: 'selectCustom',boxWidth:310,selWidth:150,multiMode:true, data:listerTreeData,child:
  327. {type:'listerTree',listerWidth:120,listerHeight:120}},
  328. render:function (item){
  329. if(!item.child7){
  330. return "";
  331. }
  332. // alert(JSON.stringify(listerTreeDataFormat))
  333. var itemArray=item.child7.split(",");
  334. var childStr="";
  335. for (var i = 0; i < itemArray.length; i++){
  336. for (var j = 0; j <listerTreeDataFormat.length; j++){
  337. if (listerTreeDataFormat[j]['id'] == itemArray[i]){
  338. childStr=childStr+listerTreeDataFormat[j]['name']+",";
  339. continue;
  340. }
  341. }
  342. }
  343. if (childStr.length > 0 ){
  344. childStr = childStr.substring(0, childStr.length-1);
  345. }
  346. return childStr;
  347. }},
  348. { display: '自动提示框', name: 'city', align: 'left', width: 155,editor: { type: 'suggestion',data:listdata,inputWidth:150,showList:true },render:function (item){
  349. for (var i = 0; i < listdata["list"].length; i++)
  350. {
  351. if (listdata["list"][i]['value'] == item.city)
  352. return listdata["list"][i]['key']
  353. }
  354. return item.city;
  355. }}
  356. ],
  357. url: '<%=path%>/getUserdbs.action', sortName: 'userId',rownumbers:true,checkbox:true,pageSize:10,dataAction:"server",usePager: true,
  358. height: "100%", width:"100%",enabledEdit: true,onBeforeEdit: onBeforeEdit, onBeforeSubmitEdit: onBeforeSubmitEdit,onAfterEdit: onAfterEdit
  359. });
  360. }
  361. //查看
  362. function onView(rowid){
  363. }
  364. //删除
  365. function onDelete(rowid,rowidx){
  366. }
  367. //编辑前事件
  368. function onBeforeEdit(e)
  369. {
  370. var str="编辑前事件,可阻止某些行或列进行编辑。列名:"+e.column.name+";行号:"+e.rowindex+";编辑前的值:"+e.value+"\n";
  371. }
  372. //编辑提交前事件
  373. function onBeforeSubmitEdit(e){
  374. }
  375. //编辑后事件
  376. function onAfterEdit(e)
  377. {
  378. //var str="编辑后事件,用于ajax提交处理。列名:"+e.column.name+";行号:"+e.rowindex+";编辑后的值:"+e.value+"\n";
  379. }
  380. </script>
  381. </body>
  382. </html>