Hi
I am having issues with using the IgxGridState directive when there are multiple grids on the page since they all need there own state directive. When you include the directive on the grid there doesn't seem to be anyway to give it a unique id so I can't distinguish them when using ViewChild. I also can't see anyway to get the state from the grid itself. Is there anyway currently to be able to link the state to a specific grid?
The IgxGridState directive contains the grid it is bound to.
When having multiple grids with the directive applied, you need to query those using the @ViewChildren decorator. From the query list you can take the directive that you need by comparing the grid id:
@ViewChildren(IgxGridStateDirective) public state: QueryList<IgxGridStateDirective>; const stateDirective = this.state.find(st => st.grid.id === grid.id);
Thanks. I tried above but it says
Property 'grid' is private and only accessible within class 'IgxGridStateDirective'
So it seems like I can't access the grid to check that. Is there another way?
I have logged an issue to enhance this. Please monitor its status at https://github.com/IgniteUI/igniteui-angular/issues/8011
Meanwhile, cast the `grid` property to any object to resolve compilation error:
(this.state.grid as any).id
Great that is working now. Thanks
Hello Katy,
I am glad that you find Hristo`s suggestion helpful.
Thank you for using I|Infragistics components!