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
250
how to dynamically generate IgxGrid columns
posted

hello,

i m trying to import igxGridColumncomponent but i think there is no such component present in ignite ui library. basically i want to generate grids column automatically how can i do that programatically without using templates.

Parents
  • 20255
    Offline posted

    Hello Alok Shashi,

    There is such component (column.component.ts file)

    Possible use:

    ...

    import {
        IgxGridComponent, IgxButtonGroupComponent, IgxColumnComponent
    } from 'igniteui-angular';

    ...

    initColumns(event: IgxColumnComponent) {
     const column: IgxColumnComponent = event;
     if (column.field === 'Name') {
      column.filterable = true;
     }
    }

    ...

    It is not possible to generate columns automatically and assign them to the grid. The correct and recommended ways is by using templates or by using the autoGenerate property. 

    Approach that you could follow, add <igx-column> in the template and use "*ngFor="let col of columns" in order to add as many columns as you want in the Grid.

Reply Children