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

[Kendo Angular Grid] - How to get currently selected rows?

2 Answers 7275 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Amit
Top achievements
Rank 1
Amit asked on 22 May 2020, 08:11 PM

Hi,

 

I am trying to get currently selected rows from a kendo angular grid and perform some operations for selected rows (such as call an external API using information from selected rows).

- user can select one row

- user can select multiple rows using `shift`

- user can select multiple sections using combination of `shift` and `ctrl`

 

I tried to use `selectionChange` which knows only the current selected rows and not previously selected.Tried to follow this: https://www.telerik.com/forums/how-to-get-the-selected-row-data-item which did not work either.

 

Please provide a sample get list of selected rows at will from the grid. It is fine even if I can get `id` column for selected rows as I can filter through the original data and get other columns for selected ids.

2 Answers, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 26 May 2020, 10:00 AM

Hi Amit,

Thank you for the provided link.

Indeed the ways described in the forum thread from my colleagues are still valid. In general the Grid provides an out of the box solution for storing the selection into a collection of selected items. By making use of the SelectionDirective, the selectedKeys array can be specified. This option gives full control over the selection. Also, the selectedKeysChange event is emitted each time when the collection has been updated, bu returning a list of indexes (or by field specified with kendoGridSelectBy property ):

https://stackblitz.com/edit/angular-6nehij?file=app/app.component.ts

To get the whole dataItem, the received collection can be iterated and with some custom logic the selected dataItem could be extracted from the Grid data:

https://stackblitz.com/edit/angular-6nehij-pva89b?file=app/app.component.ts

I hope this helps.

Regards,
Martin
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Amit
Top achievements
Rank 1
answered on 27 May 2020, 05:14 PM
thanks! `selectedKeysChange` event worked fine.
Tags
General Discussions
Asked by
Amit
Top achievements
Rank 1
Answers by
Martin
Telerik team
Amit
Top achievements
Rank 1
Share this question
or