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
215
IgxGridState directive - multiple grids
posted

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?

Parents
No Data
Reply
  • 16310
    Offline posted

    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);
    Please let me know if you have further questions.
Children