Hello,
I am having some trouble binding my data to the IgHierarchicalGrid. We are using igniteui with a Angular/Typescript front end stack.
I am initializing the grid options / data source in my constructor :
constructor(private _accountService: AccountService, private _hierarchicalGridOptions: HierarchicalGridOptions, private _route: ActivatedRoute, private _router: Router) { this.hGridOptions = this._hierarchicalGridOptions.getGridOptions(this.myData); }
Where this.MyData is an empty array, that represents my data structure, Here I am passing it a method on an injectable that scaffolds my grids.
Next in the ngOnInit() I am filling in this.MyData from a service call and re-passing it in to the grid options, my understanding is that the grid should data bind this new data, which it is, however, it is being bound twice!
Here is my onInit:
ngOnInit(): void { this._route.params .switchMap((params: Params) => this._accountService.getData(+params["id"])) .subscribe(s => { this.MyData = s; this.hGridOptions = this._hierarchicalGridOptions.getGridOptions(this.myData);
}, error => this.errorMessage = <any>error); }
Any help will be much appreciated!
Hello Christian,
Could it be because first you initialize the igHierarchicalGrid options in the constructor? That will trigger the dataBould event the first time. The second time the dataBound will be triggered by the subscribe function when it is being executed, because you set the igHierarchicalGrid options there as well.
Note that the igHierarchicalGrid will be recreated every time the options are being fully recreated and this would lead to the data being bound again.
If this is not the case, could it be that what you mean is the data being bound twice inside that subscribed function? Aside from the constructor initialization.
Regards,Svetoslav Krastev,Infragistics