easyui-tree.动态展开节点
2012-12-13 15:14
465 查看
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@taglib uri="/struts-tags" prefix="s"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <base href="<%=basePath%>"> <title></title> <link rel="stylesheet" type="text/css" href="<%=basePath%>easyui/themes/default/easyui.css"/> <link rel="stylesheet" type="text/css" href="<%=basePath%>easyui/themes/icon.css"/> <script type="text/javascript" src="<%=basePath%>easyui/jquery-1.7.2.min.js"></script> <script type="text/javascript" src="<%=basePath%>easyui/jquery.easyui.min.js"></script> <script type="text/javascript" src="<%=basePath%>easyui/locale/easyui-lang-zh_CN.js"></script> <script type="text/javascript"> $(function(){ //动态获取tree,行政区列表 $('#xianTree').tree({ checkbox : true, onlyLeafCheck:true, url : "xmlx/projectSelectionAction!getDeptTrees.action?departid=2939", onBeforeExpand : function(node, param) { $('#xianTree').tree('options').url = "xmlx/projectSelectionAction!getDeptTrees.action?departid="+node.id;// change the url }, onCheck:function(data, checked) { } }); //给页面所有年份赋值 var myDate = new Date(); //js得到当前日期 var endyear=myDate.getFullYear(); //得到当前年 for(var i=endyear;i>=2009;i--){ $("#year").append('<option value="'+i+'">'+i+'年</option>'); //查询年份赋值 } //遍历选中的行政区 $("#setMsg").click(function(){ var year=$("#year").val(); var entytype=$("input[name='entytype']:checked").val(); var nodes = $('#xianTree').tree('getChecked'); var msgJson="["; for (var i = 0; i < nodes.length; i++) { msgJson+="{"; msgJson+="districtcode:"+nodes[i].attributes.districtcode+","; msgJson+="year:"+year+","; msgJson+="entytype:"+entytype+""; msgJson+="}"; if(i+1>=nodes.length){ msgJson+=""; }else{ msgJson+=","; } } msgJson+="]"; $.ajax({ type:"post", url:"jbxxlr/countyrecordTypeAction!addCountyRecordTypes.action", data:{jsonstr:msgJson}, success:function(msg){ $.messager.alert("系统提示","保存成功"); }, error:function(){ $.messager.alert("系统提示","保存成功"); } }); }); }); </script> </head> <body class="easyui-layout" > <div region="west" style="width:200px;"> <ul id="xianTree"></ul> </div> <div region="center" class="easyui-layout"> <div region="center" style="text-align:center;"> 年份:<select id="year"> </select><br /> 填报类型:<input type="radio" value="2" name="entytype"/>县 <input type="radio" value="1" name="entytype" />镇 <input type="radio" value="0" name="entytype" />村 </div> <div region="south" style="height:30px; line-height:30px; text-align:right;" border="false"> <a class="easyui-linkbutton" id="setMsg" iconCls="icon-ok">确定</a> <a class="easyui-linkbutton" id="cancel" iconCls="icon-cancel">取消</a> </div> </div> </body> </html>
当然这是需要后天给予返回有效的json数据的。
相关文章推荐
- easyUI treeGrid 惰性加载,动态加载,无论有无子节点都显示展开图标
- easyUI treereload之后保持原来节点的展开状态
- easyui treegrid动态加载节点
- easyUI tree的展开和收缩操作以及节点赋值操作
- Easyui中tree组件实现搜索定位功能及展开节点定位
- (转)jQuery EasyUI Tree - TreeGrid动态加载子节点
- easyui tree/TreeGrid使用:逐级加载、指定节点刷新、全部展开
- (转)EasyUI组件tree只展开根节点下的一级子节点或二级子节点
- 【easyui】tree双击展开
- 在Flex中让Tree绑定数据后自动展开树节点
- 拖拽时自动展开 Tree 节点
- Extjs4.2 TreePanel+Asp.net mvc 动态加载节点
- [ProE (Creo) 二次开发] 实现Dialog中Tree的Node节点的展开和折叠
- easyui-tree动态获取后台数据成为书结构的操作
- FLEX中Tree默认展开全部节点
- easyui treegrid 获取子节点
- FLEX中Tree默认展开所有节点
- Easyui treegrid可编辑状态下动态设置numberspinner类型列的max
- Flex tree 展开任意想展开的节点
- jquery easyui tree异步加载子节点