easyui combotree加载数据

easyui 复选下拉树combotree从后台form表单加载数据总是加载不上。例如:

<input type=”text” id=”tpformkjbhIds”
class=”easyui-combotree” multiple=”true”
url=”<c:url value=’/nnmis/view/sys/gainEqtTreeForZhujianByOwnerEQTTREE.tg’/>?orgnum=00″
name=”vo.kjbhIds” style=”width:180px” valueField=”id”
textField=”text” ></input>

为此,在form里面多封装一个变量:

<input type=”hidden” id=”formkjbhIdsCopy”
name=”vo.kjbhIdsCopy”>

其值与tpformkjbhIds完全一样。然后在combotree的onloadsuccess事件中特殊处理:

$(‘#tpformkjbhIds’).combotree(‘tree’).tree({
‘onLoadSuccess’:function(){
$(‘#tpformkjbhIds’).combotree(‘tree’).tree(‘collapseAll’);
var formkj = $(‘#formkjbhIdsCopy’).val();
if(formkj!=null && formkj.length>0){
var allnodes = $(‘#tpformkjbhIds’).combotree(‘tree’).tree(‘getChildren’);
for(var i=0;i<allnodes.length;i++){
if(formkj.indexOf(allnodes[i].id) != -1){
$(‘#tpformkjbhIds’).combotree(‘tree’).tree(‘check’,allnodes[i].target);
}
}
}
}
});

如果form中加载到的值不为空,则对下拉树遍历并选中值中包含的节点。例如form中加载到了1,3,5,则将树中id包含在其内的节点选中。

This entry was posted in javascript. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s