今天要写一个获得dhtmlXTree 节点值的,大量的Id节点值要传递到后台去做分析处理,网上搜索了好多东西,都无法满足我的需求,就自己琢磨了半天,弄出来了!
还是一句话,约定是很重要的,一个很好的取名,与规范的取名就能解决一个棘手问题;
我的根节点的id名称为:rootindexsystem;
二级节点为:indexSystem_1(1是个递增的数字)
三级节点为:indexItem_1(1是个递增的数字)
但是你直接要获得它的值是无法获取的!看看他生成的文件时<table ><tr><td>的形式
所以还得用javascript 来获得:
<script type="text/javascript">
var indexIds;
var path="";
function verify() {
if($j('input[@type=radio][@checked]').length == 0) {
alert("对不起!你还没有选择地区,无法进行分析!请选择地区!");
return false;
}
indexIds = tree.getAllChecked();
//var surveyAreaID = document.getElementsByName("surveyAreaID").value();
var surveyAreaID = $j('input[@type=radio][@checked]').val();
path ="/short/indexCurrentCompetition!staticIndex.action?surveyAreaID="+surveyAreaID+"&indexIds="+indexIds;
editNew(path);
}
</script>
使用一个按钮去触发verify()事件:
<img id="watersearch" style='cursor: pointer' src="/images/bottom_search.gif"
width="52" height="18" border="0" onclick="verify()" />
到后台之后的数据就是这样一个字符串;
rootindexsystem,indexSystem_1,indexItem_1,indexItem_2,indexItem_3,indexItem_4,indexItem_5,indexItem_6,indexItem_8,indexItem_9,indexItem_10,indexSystem_2,indexItem_129,indexItem_130,indexSystem_3,indexItem_131,indexItem_132,indexItem_133,indexItem_134,indexItem_135,indexItem_136,indexItem_137,indexItem_138,indexItem_139,indexItem_140,indexItem_141,indexItem_142,indexItem_143,indexItem_144,indexItem_145,indexItem_146,indexItem_160,indexItem_200,indexItem_201,indexItem_225,indexItem_243,indexItem_244,indexItem_245,indexItem_246,indexItem_247,indexItem_248,indexItem_249,indexItem_250,indexItem_251,indexItem_252,indexItem_253,indexItem_254,indexItem_255,indexItem_256,indexItem_257,indexItem_258";
对其进行解析代码如下:
private Map<Integer, List<Integer>> initIndexIds(String indexIds){
String [] indexSystems = indexIds.split("indexSystem_");
int indexSystemIDs[] = new int[indexSystems.length-1];
Map<Integer, List<Integer>>indexIdKeyItemIdArray=new HashMap<Integer, List<Integer>>();
for(int i=1;i<indexSystems.length;i++) {//指标体系的id数组
indexSystemIDs[i-1] = Integer.parseInt(indexSystems[i].split(",")[0]);
String tempIndexItem = indexSystems[i].substring(2, indexSystems[i].length());
String indexItemIds[] = tempIndexItem.split("indexItem_");
List<Integer> itemIds = new ArrayList<Integer>();
for (String s : indexItemIds) {
if(s.indexOf(",")>-1) {
s=s.substring(0, s.length()-1);
}
if(!s.equals("")) {
itemIds.add(Integer.parseInt(s));
}
}
indexIdKeyItemIdArray.put(indexSystemIDs[i-1], itemIds);
}
return indexIdKeyItemIdArray;
}
问题就这样的解决了!
分享到:
相关推荐
dhtmlXtree树 右dhtmlXtree键菜单
dhtmlxtree和json的应用。自己写的练习项目,免费下载。
专业版dhtmlxtree下载 专业版dhtmlxtree下载
dhtmlxTree代码,通过加载后台XML组建树结构,前台使用JS加载
dhtmlxtree例子
包含dhtmlxTree(树型控件),dhtmlxTabbar(选项卡),dhtmlxGrid(数据表格),dhtmlxCombo(下拉选项),dhtmlxTreeGrid(树型表格),dhtmlxVault(文件上传控件),dhtmlxMenu(菜单),dhtmlxToolbar(工具条),dhtmlxCalendar(日历...
dhtmlxtree中文开发指导,简单介绍dhtmlxtree的使用。初学者适合。
dhtmlxTree 树形控件 JavaScript
dhtmlXTree1.6,js实现的树结构的目录
第三方树控件dhtmlxTree 3.6
dhtmlxtree实例包括复选、右键菜单、拖拽等功能
dhtmlxtree构建动态维护树,介绍dhtmltree的构建以及修改!
dhtmlxTree专业版
DHtmlXTree 调用xml http://blog.csdn.net/ymc0329/article/details/6619796
dhtmlxTree 最好的tree控件
JS 带右键菜单的目录树 dhtmlxtree+proto.menu 分权限 JS 带右键菜单的目录树 dhtmlxtree+proto.menu 分权限 图片预览 ...
从版本2.0,dhtmlxLayout提供了 DHTMLX组件与其他高层次的集成 ,如 dhtmlxGrid ,dhtmlxTree , dhtmlxWindows , dhtmlxMenu 等窗格集成组件可以在全球的应用和分别为每个布局。 有了一个新的皮肤2.5版本,介绍,...