概述
获取当前combotree选中的节点,但是是数组,可以遍历数组转换成string类型,遍历方法可参考文章js遍历方法,选取效率最高的方法。
< input class = "easyui-combotree"style = "width:150px"type = "text"
id = "citys" name = "city" class = "easyui-validatebox"
data-options = "prompt:'城市',required:true,multiple:true,missingMessage:'请添加城市'" >
//
$('#citys').combotree({
url: 'city/getTreeData.do',
valueField: 'id',
textField: 'text',
multiple: true,
checkbox: true
});
//获取当前combotree的tree对象
var tree = $('#citys').combotree('tree');
//获取当前选中的节点
var data = tree.tree('getChecked');
var idString = "";
for (i = 0, len = data.length; i < len; i++) {
idString += data[i].id + ",";
}
//截取最后一个逗号
var idStrings = idString.substring(0, idString.length - 1);