消息关闭
    暂无新消息!
如图

返回数据

[{"id":"1","name":"\u5317\u4eac","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u5317","children":[{"id":"36","name":"\u5317\u4eac\u5e02","parentid":"1","sign":"","deep":"2","listorder":"0","region":null,"children":[{"id":"37","name":"\u4e1c\u57ce\u533a","parentid":"36","sign":"","deep":"3","listorder":"0","region":null,"children":[]},{"id":"38","name":"\u897f\u57ce\u533a","parentid":"36","sign":"","deep":"3","listorder":"0","region":null,"children":[]},{"id":"41","name":"\u671d\u9633\u533a","parentid":"36","sign":"","deep":"3","listorder":"0","region":null,"children":[]},{"id":"42","name":"\u4e30\u53f0\u533a","parentid":"36","sign":"","deep":"3","listorder":"0","region":null,"children":[]},{"id":"43","name":"\u77f3\u666f\u5c71\u533a","parentid":"36","sign":"","deep":"3","listorder":"0","region":null,"children":[]},{"id":"44","name":"\u6d77\u6dc0\u533a","parentid":"36","sign":"","deep":"3","listorder":"0","region":null,"children":[]},{"id":"45","name":"\u95e8\u5934\u6c9f\u533a","parentid":"36","sign":"","deep":"3","listorder":"0","region":null,"children":[]},{"id":"46","name":"\u623f\u5c71\u533a","parentid":"36","sign":"","deep":"3","listorder":"0","region":null,"children":[]},{"id":"47","name":"\u901a\u5dde\u533a","parentid":"36","sign":"","deep":"3","listorder":"0","region":null,"children":[]},{"id":"48","name":"\u987a\u4e49\u533a","parentid":"36","sign":"","deep":"3","listorder":"0","region":null,"children":[]},{"id":"49","name":"\u660c\u5e73\u533a","parentid":"36","sign":"","deep":"3","listorder":"0","region":null,"children":[]},{"id":"50","name":"\u5927\u5174\u533a","parentid":"36","sign":"","deep":"3","listorder":"0","region":null,"children":[]}]}]},{"id":"2","name":"\u5929\u6d25","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u5317","children":[{"id":"40","name":"\u5929\u6d25\u5e02","parentid":"2","sign":"","deep":"2","listorder":"0","region":null,"children":[]}]},{"id":"3","name":"\u6cb3\u5317","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u5317","children":[]},{"id":"4","name":"\u5c71\u897f","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u5317","children":[]},{"id":"5","name":"\u5185\u8499\u53e4","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u5317","children":[]},{"id":"6","name":"\u8fbd\u5b81","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u4e1c\u5317","children":[]},{"id":"7","name":"\u5409\u6797","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u4e1c\u5317","children":[]},{"id":"8","name":"\u9ed1\u9f99\u6c5f","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u4e1c\u5317","children":[]},{"id":"9","name":"\u4e0a\u6d77","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u4e1c","children":[{"id":"39","name":"\u4e0a\u6d77\u5e02","parentid":"9","sign":"","deep":"2","listorder":"0","region":null,"children":[]}]},{"id":"10","name":"\u6c5f\u82cf","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u4e1c","children":[]},{"id":"11","name":"\u6d59\u6c5f","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u4e1c","children":[]},{"id":"12","name":"\u5b89\u5fbd","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u4e1c","children":[]},{"id":"13","name":"\u798f\u5efa","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u5357","children":[]},{"id":"14","name":"\u6c5f\u897f","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u4e1c","children":[]},{"id":"15","name":"\u5c71\u4e1c","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u4e1c","children":[]},{"id":"16","name":"\u6cb3\u5357","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u4e2d","children":[]},{"id":"17","name":"\u6e56\u5317","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u4e2d","children":[]},{"id":"18","name":"\u6e56\u5357","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u4e2d","children":[]},{"id":"19","name":"\u5e7f\u4e1c","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u5357","children":[]},{"id":"20","name":"\u5e7f\u897f","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u5357","children":[]},{"id":"21","name":"\u6d77\u5357","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u534e\u5357","children":[]},{"id":"22","name":"\u91cd\u5e86","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u897f\u5357","children":[]},{"id":"23","name":"\u56db\u5ddd","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u897f\u5357","children":[]},{"id":"24","name":"\u8d35\u5dde","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u897f\u5357","children":[]},{"id":"25","name":"\u4e91\u5357","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u897f\u5357","children":[]},{"id":"26","name":"\u897f\u85cf","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u897f\u5357","children":[]},{"id":"27","name":"\u9655\u897f","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u897f\u5317","children":[]},{"id":"28","name":"\u7518\u8083","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u897f\u5317","children":[]},{"id":"29","name":"\u9752\u6d77","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u897f\u5317","children":[]},{"id":"30","name":"\u5b81\u590f","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u897f\u5317","children":[]},{"id":"31","name":"\u65b0\u7586","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u897f\u5317","children":[]},{"id":"32","name":"\u53f0\u6e7e","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u6e2f\u6fb3\u53f0","children":[]},{"id":"33","name":"\u9999\u6e2f","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u6e2f\u6fb3\u53f0","children":[]},{"id":"34","name":"\u6fb3\u95e8","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u6e2f\u6fb3\u53f0","children":[]},{"id":"35","name":"\u6d77\u5916","parentid":"0","sign":"","deep":"1","listorder":"0","region":"\u6d77\u5916","children":[]}]



也定义了valueField:'name',  textField:'name',
       

$('#so2').combotree({
            valueField:'name',
        textField:'name',
        url:'__URL__/treeload/json/1',
        striped:true,
        method:'get',
        
       
     });

求解。

7个回答

︿ 1
人家json里面需要的明明是 id 和 text 作为key,所以嘛就undefined喽
︿ 1
combotree中的tree继承自tree,并没有实现combobox的valueField和textField属性,需要自己写loadFilter:
参考:
//作者孙宇
//自定义loadFilter的实现
$.fn.tree.defaults.loadFilter = function (data, parent) {
var opt = $(this).data().tree.options;
var idField,
textField,
parentField;
if (opt.parentField) {
idField = opt.idField || 'id';
textField = opt.textField || 'text';
parentField = opt.parentField;

var i,
l,
treeData = [],
tmpMap = [];

for (i = 0, l = data.length; i < l; i++) {
tmpMap[data[i][idField]] = data[i];
}

for (i = 0, l = data.length; i < l; i++) {
    if (tmpMap[data[i][parentField]] && data[i][idField] != data[i][parentField]) {
        if (!tmpMap[data[i][parentField]]['children'])
            tmpMap[data[i][parentField]]['children'] = [];
data[i]['text'] = data[i][textField];
tmpMap[data[i][parentField]]['children'].push(data[i]);
} else {
data[i]['text'] = data[i][textField];
treeData.push(data[i]);
}
}
return treeData;
}
return data;
};