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

Row Click

1 Answer 5830 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ron
Top achievements
Rank 1
Ron asked on 17 Feb 2021, 04:54 AM

This might have been answered before.

I need to open a modal window on row click, but here's the catch:

There are two ways I think this might work but the two ways need a workaround.

1st: using the selectionChange event, the problem is that the row stays selected and when I close the modal and would like to select it again it wont let me, I have to select a different row to trigger the event.

2nd: cellClick event, it works fine, but I have a column at the end of the row with button actions for delete, etc... so if I click on any of those buttons the cellClick event also gets fired and I end up with two actions.

What would be a clean way to trigger a row click without it being selected and open a modal window, and when clicking on any button on a row cell it doesn't trigger the row click event either.

Thanks.

1 Answer, 1 is accepted

Sort by
1
Dimiter Topalov
Telerik team
answered on 18 Feb 2021, 08:19 AM

Hi Ron,

Depending on the selectionChange event for performing actions when a Grid row is clicked is indeed not optimal - rows are selected on click, but to deselect a row (and thus trigger the selectionChange event), the end user needs to hold the control button while clicking:

https://www.telerik.com/kendo-angular-ui/components/grid/selection/row-selection/#toc-single-row-selection

The cellClick event handler is the most suitable spot for performing the custom logic related to opening the modal window. The event data contains the original mouse event that triggered the cellClick event, and thus the necessary custom conditional logic can be applied based on the click event target - if it is a button just return from the handler before opening the dialog, for example:

https://stackblitz.com/edit/angular-v4mnrm-bptgab?file=app%2Fapp.component.ts

The conditional logic can be further modified to check for the clicked column, row, cell, etc.

I hope this helps.

Regards,


Dimiter Topalov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Ron
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question
or