Hi,
We are using kendo-grid in out project and there is a requirement that the first row be selected by default on load. (once the data is retrieved and grid is initialized)
How do I achieve this? The documentation doesn't seem to indicate how this can be done.
Any help is greatly appreciated.
Regards,
Jyothi
4 Answers, 1 is accepted
Hello Jyothi,
The developer can programmatically set the selection, as shown here.
This could be easily done by configuring the selectedKeys option, which provides control over the selection functionality.
Please, check the following example:
https://stackblitz.com/edit/angular-s8b7di?file=app/app.component.ts
Let us know, if you need further assistance.
Regards,
Preslava
Progress Telerik

Hi Preslava,
Thank you for the prompt reply. This is very helpful.
Regards,
Jyothi

Hi Preslava,
While this is good to select the first row after the data loads, is there a way to trigger selectionChange event? We have to this common component that need to emit some data once a row is selected,so all the other components that use this common component can enable and disable buttons etc.
The object emitted by the selectionChange is quite different from the grid data itself, so wondering if you have any suggestion on how to achieve this.
Regards,
Jyothi
Hello Jyothi,
By design the events in the Kendo UI for Angular components occur as a result of some user interaction, for example on click.
If needed, one can programmatically set custom logic in the ngOnInit or ngAfterViewInit lifecycle hooks. In this case, mySelection collection already has an initial value, so it can be used in the logic.
Please check the following example:
https://stackblitz.com/edit/angular-ql6cnu?file=app/app.component.ts
Further information about the SelectionEvent object structure could be found here.
I hope this helps.
Regards,
Preslava
Progress Telerik