1
votes

Currently, I want to select the first row in Kendo Grid. Here is my code: in Component:

export class SampleComponent{  
  gridView: GridDataResult; 
  mySelection: number[] = [0]; 
  state: State = { skip: 0, take: 6, sort: [{ dir: "desc", field: "id" }]};
  ...  
}

In HTMl:

<kendo-grid id="grid" 
   [data]="gridView" [pageSize]="state.take" 
   [skip]="state.skip" [selectable]="true" 
   (selectionChange)="onSelect($event)" 
   (sortChange)="sortChange($event)" 
   [sort]="state.sort" [filter]="state.filter" 
   [sortable]="true" [kendoGridSelectBy]="'id'" 
   [selectedKeys]="mySelection" [height]="'auto'" [scrollable]="'none'">

My issue is: the first row of Grid is not selected. How do i workaround with it?

Please help me.

1
update html: <kendo-grid id="grid" [data]="gridView" [pageSize]="state.take" [skip]="state.skip" [selectable]="true" (selectionChange)="onSelect($event)" (sortChange)="sortChange($event)" [sort]="state.sort" [filter]="state.filter" [sortable]="true" [kendoGridSelectBy]="'id'" [selectedKeys]="mySelection" [height]="'auto'" [scrollable]="'none'"> - Peter Chan

1 Answers

0
votes

It sounds like you want to select by rowIndex, but you are supplying a key ( 'id') to [kendGridSelectBy], overriding the default.

Change

    [kendoGridSelectBy]="'id'" 

to

    kendoGridSelectBy

and it should select