Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1165
Angular2 and late binding
posted

Hi,

I am trying to use the igTree with an angular 2 app. 
When I try to bind the data to the dataSource with data that comes from a remote server (or a button click for the matter), the tree is left empty.

If I set the data in the constructor - it all work fine.
I used the samples from the github page :

I set the data in the constructor to an empty array, and load the data on a button click through the loadData() method:

 

constructor() {
// this.data = ProductCategories.getData();

this.data = [];

this.newProductCategory= { "Name": "",
"ProductCategoryID": this.data.length+1,
"ProductSubcategories":[]
};

this.newProductSubcategory={
"Name": "",
"ProductSubcategoryID": 0
};
this.options = {
dataSource: this.data,
bindings: {
childDataProperty : "ProductSubcategories",
textKey : "Name",
valueKey : "ProductCategoryID"
}
};

}
loadData(){
this.data = ProductCategories.getData();
this.options.dataSource = this.data;
}

 

Any help will be welcomed

Thank

Parents Reply Children
No Data