I am wondering if there is any sort of callback functions that can be used on TreeGrid.setFields() and Tree.setRoot() - I could not find any.
It seems that these functions are asynchronous and I can not figure out how to detect their completion.
If I want to do something special right after grid was populated using functions above - for example TreeGrid.getBody() or TreeGrid.autoFitFields() or anything else - how would I achieve that without using setTimeout()?
The code below demonstrates what I mean: if right after populating grid with TreeGrid.setFields() and Tree.setRoot() I call TreeGrid.getBody() - the body does not exist yet, and TreeGrid.autoFitFields() is ignored, but with setTimeout() - they both work fine.
Interestingly, in the same scenario calling Tree.openAll() right after populating the grid works as expected.
Please advice.
It seems that these functions are asynchronous and I can not figure out how to detect their completion.
If I want to do something special right after grid was populated using functions above - for example TreeGrid.getBody() or TreeGrid.autoFitFields() or anything else - how would I achieve that without using setTimeout()?
The code below demonstrates what I mean: if right after populating grid with TreeGrid.setFields() and Tree.setRoot() I call TreeGrid.getBody() - the body does not exist yet, and TreeGrid.autoFitFields() is ignored, but with setTimeout() - they both work fine.
Interestingly, in the same scenario calling Tree.openAll() right after populating the grid works as expected.
Please advice.
Code:
isc.TreeGrid.create({
ID: "employeeTree",
data: isc.Tree.create({
modelType: "children",
nameProperty: "Name",
childrenProperty: "directReports"
}),
width: 500,
height: 400,
autoFitWidthApproach:"both"
});
employeeTree.getData().setRoot({EmployeeId: "1", directReports: [
{EmployeeId:"4", Name:"Charles Madigen", directReports: [
{EmployeeId:"188", Name:"Rogine Leger"},
{EmployeeId:"189", Name:"Gene Porter", directReports: [
{EmployeeId:"265", Name:"Olivier Doucet"},
{EmployeeId:"264", Name:"Cheryl Pearson"}
]}
]}
]});
employeeTree.setFields([
{name: "Name"},
{name: "EmployeeId"}
]);
if(employeeTree.getBody()){
isc.say("Body exists");
}else{
isc.say("Body does not exist")
}
employeeTree.autoFitFields();
setTimeout(function(){
employeeTree.autoFitFields();
if(employeeTree.getBody()){
isc.say("Body exists");
}else{
isc.say("Body does not exist")
}
},2000);
Comment