[英]How to get all children in kendo ui treelist?
How can I get all the children for selected row in kendo ui treelist :如何获取剑道 ui 树列表中选定行的所有子项:
I want to get direct children for Backframe
that would be level 3 rows.我想为
Backframe
获得第 3 行的直接子级。
You need to iterate through the datasource comparing the id of the row to the parentid of each row:您需要遍历数据源,将行的 id 与每行的 parentid 进行比较:
change: function(e) {
var selectedRows = this.select();
if (selectedRows.length > 0){
var dataItem = this.dataItem(selectedRows[0]);
var curID = dataItem.id;
var ds = $(this)[0].dataSource.data();
var children = [];
for (var i=0; i<ds.length; i++){
var pid = ds[i].parentId;
if (pid == curID){
children.push(ds[i].Name)
}
}
alert(children);
}
},
TreeList has dataSource.childNodes method for this purpose.为此,TreeList 具有dataSource.childNodes方法。
change: function(e) {
var selectedRows = this.select();
if (selectedRows.length > 0){
var dataItem = this.dataItem(selectedRows[0]);
var children=this.dataSource.childNodes(dataItem);
console.log(children);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.