EasyUI在项目中的相关使用
来源:互联网 发布:csi接口 数据通信协议 编辑:程序博客网 时间:2024/06/06 03:31
最近项目是采用Easyui作为前端页面,正好此次前端页面由我来编写,在这总结部分使用方法及技术,同时还有相关的JS控制代码,在这里只是实用技巧,如果需要更详细的情况,需要去查看API文档 http://www.jeasyui.net/
一、异步树
<table id="peopleGrid" style="height: 100%;"></table>$('#moduleTree').tree({ url: contextPath +'/', //URL地址 loadFilter: function(rows){ return convert(rows); }, onBeforeExpand: function(node){ if(node){ $('#moduleTree').tree('options').url = contextPath + "/" + node.id; } }, onDblClick: function(node){ //获取节点后给相应的文本框赋值 areaID = node.id } });function convert(rows){function exists(rows, parentDeptCode){ for(var i=0; i<rows.deptList.length; i++){ if (rows.deptList[i].deptCode == parentDeptCode) return true; } return false; } var nodes = []; // get the top level nodes for(var i=0; i<rows.deptList.length; i++){ var row = rows.deptList[i]; if (!exists(rows, row.parentDeptCode)){ nodes.push({ id:row.deptCode, text:row.deptName, state:'closed' }); } } var toDo = []; for(var i=0; i<nodes.length; i++){ toDo.push(nodes[i]); } while(toDo.length){ var node = toDo.shift();// the parent node // get the children nodes for(var i=0; i<rows.deptList.length; i++){ var row = rows.deptList[i]; if (row.parentDeptCode == node.id){ var child = {id:row.deptCode,text:row.deptName,state:'closed'}; if (node.children){ node.children.push(child); } else { node.children = [child]; } toDo.push(child); } } } return nodes; }
二、下拉框(此处写的下拉框与API有些差别,我是采用AJAX异步提交的方式和下拉框组合实现)
//获取组别下拉信息 $.ajax({ type: "POST", url:contextPath +'/' , //url地址 contentType: "application/x-www-form-urlencoded; charset=UTF-8", dataType : "json", success: function(data){ var listData = data; $("#updateSeatGroupName").combobox({ valueField:'seatGroup', textField:'seatGroupName', value:selectDefault, data:listData.groupList, editable:false, onSelect:function(record){ seatGroupNo = record.seatGroup seatGroupName = record.seatGroupName } }); } });
三、单选按钮默认选中
实例:initradio('status',status);方法://获取单选按钮默认选中function initradio(rName, rValue) {var rObj = document.getElementsByName(rName);for (var i = 0; i < rObj.length; i++) {if (rObj[i].value == rValue) {rObj[i].checked = 'checked';}}}
四、JQ中控制文件框只读
设置只读 $("#updateSeatGroupName").attr({readonly: "true"}); 取消只读 $("#updateSeatGroupName").removeAttr("readonly");
2 0
- EasyUI在项目中的相关使用
- easyui tree在struts1中的使用
- easyui-tabs使用相关
- 项目在使用easyui时遇到的问题
- 在easyUI中使用DataGrid组件更改单元格中的值
- easyUI中的表格使用
- ANT 在项目中的使用
- lucene 在项目中的使用
- ldap在项目中的使用
- Granule 在项目中的使用
- GSON在项目中的使用
- log4j在项目中的使用
- AES在项目中的使用
- CocoaPods在项目中的使用
- Aidl在项目中的使用
- gulp在项目中的使用
- 多线程在项目中的使用
- redis在项目中的使用
- 那些年,翻过山,趟过河,挖了山丘,黑了河沟,终于还是遇到了——跨服务器查询
- ZSTU4274 约素
- 看。。。很多算法问题都能找到它的现实原型
- AS与.net的交互——加载web上的xml
- AS与.net的交互——详解UrlRequest
- EasyUI在项目中的相关使用
- 挖一挖C#中那些我们不常用的东西之系列(1)——ToDictionary,ToLookup
- 挖一挖C#中那些我们不常用的东西之系列(2)——IsXXX 系列方法
- 挖一挖C#中那些我们不常用的东西之系列(3)——StackTrace,Trim
- java虚拟机理解(二)——对象访问机制
- 抛弃NVelocity,来玩玩Razor
- 我也要谈谈大型网站架构之系列(1)——纵观历史演变(上)
- javaweb面试必备知识点
- 我也要谈谈大型网站架构之系列(2)——纵观历史演变(下)