How can I get all the children for selected row in kendo ui treelist :
I want to get direct children for Backframe
that would be level 3 rows.
How can I get all the children for selected row in kendo ui treelist :
I want to get direct children for Backframe
that would be level 3 rows.
You need to iterate through the datasource comparing the id of the row to the parentid of each row:
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.
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);
}
}