selectZTree 默认值怎么设置
<t:selectZTree id="citySel" url="jeecgFormDemoController.do?getTreeData" windowWidth="400px"></t:selectZTree>在修改操作时,怎么获取原有值?selectZTree 标签没有defaultVal 属性,要怎么处理?
已经修复些缺陷,如下:
1.在easyui.tld 的selectZTree 标签添加以下属性:
<attribute>
<name>defaultVal</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
<description>默认值</description>
</attribute>
2:在 org.jeecgframework.tag.core.easyui.SelectZTreeTag 中添加
private String defaultVal;//默认值 的定义,并生成get、set方法
再在public StringBuffer end()方法中修改 showMenu 如下:
+ " function showMenu() {"
+ " var cityObj = $('#"+id+"');"
+ " var cityOffset = $('#"+id+"').offset();"
+ " var zTree = $.fn.zTree.getZTreeObj('treeDemo');"
+" var dv='"+defaultVal+"';"
+ "if(dv.length>0) "
+ " { var pd=dv.indexOf(',');"
+ " if(pd>0)"
+ " {"
+ " var dvs=dv.split(',');"
+ " for(var t=0;t<dvs.length;t++)"
+ " {"
+ " alert(dvs);"
+" var node = zTree.getNodeByParam(\"name\", dvs);"
+" zTree.checkNode(node,true);"
+ " }"
+ " }else{"
+" var node = zTree.getNodeByParam(\"name\", dv);"
+" zTree.checkNode(node,true);"
+ "}"
+ "}"
+ " $('#menuContent').css({left:cityOffset.left + 'px', top:cityOffset.top + cityObj.outerHeight() + 'px'}).slideDown('fast');"
+ " $('body').bind('mousedown', onBodyDown);"
+ "} "
3.再在最后倒数3行修改,添加默认值的判断:
if(defaultVal.isEmpty())
{
sb.append(" <input id=\""+id+"\" name=\""+id+"\"type=\"text\" readonly value=\"\" style=\"width:"+windowWidth+";height:"+windowHeight+"\" class=\"form-control\" onclick=\"showMenu();\" />");
}
else
{
sb.append(" <input id=\""+id+"\" name=\""+id+"\" value=\""+defaultVal+"\"type=\"text\" readonly value=\"\" style=\"width:"+windowWidth+";height:"+windowHeight+"\" class=\"form-control\" onclick=\"showMenu();\" />");
}
4.在JSP页面使用,在add页面为:
<t:selectZTree id="jcDept" url="jeecgFormDemoController.do?getTreeData" defaultVal=""windowWidth="250px" windowHeight="30px" selectCascadeParent="false" cancelCascadeParent="true"></t:selectZTree>
在update页面为:
<t:selectZTree id="jcDept" url="jeecgFormDemoController.do?getTreeData" defaultVal="${jformConfiguration.jcDept}" windowWidth="250px" windowHeight="30px" selectCascadeParent="false" cancelCascadeParent="true"></t:selectZTree>
页:
[1]