This is a migrated thread and some comments may be shown as answers.

Select a row on load programmatically

4 Answers 2861 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jyothi
Top achievements
Rank 1
Iron
Iron
Veteran
Jyothi asked on 27 Jan 2020, 02:02 PM

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

Sort by
0
Preslava
Telerik team
answered on 28 Jan 2020, 09:40 AM

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

Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Jyothi
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 28 Jan 2020, 01:21 PM

Hi Preslava,

Thank you for the prompt reply. This is very helpful.

Regards,

Jyothi

0
Jyothi
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 28 Jan 2020, 03:33 PM

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

0
Preslava
Telerik team
answered on 29 Jan 2020, 03:33 PM

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

Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Jyothi
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Preslava
Telerik team
Jyothi
Top achievements
Rank 1
Iron
Iron
Veteran
Share this question
or