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
90
Selected first row
posted

I am new in to the igx grid, so don't no how to selected first row  by default. So please help me into that.

Parents
  • 280
    Offline posted

    Hello,

    Thank you for contacting us!

    To be able to apply initial row selection, first you have to set the primaryKey and the rowSelectable property for the IgxGrid.

        <igx-grid #grid [data]="data" width="100%" height="500px" [primaryKey]="'ProductID'" [rowSelectable]="true">

    The initial selection is made through the IgxGrid API:

        ngAfterViewInit(){
          this.grid.selectRows([1]);
          this.grid.markForCheck();
        }

    The row indexes start from 0.

    Keep in mind that the IgxGrid ChangeDetectionStrategy is OnPush, so when you apply changes to the Grid, you have notify it, which is done with the markForCheck() method.

    I made a StackBlitz sample, based on your requirement.

    Please, take a look at the sample and let me know if you have any questions.

Reply Children