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

Row doubleclicking (again)

3 Answers 28 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 07 Feb 2016, 09:38 AM

My goal: I want to perform an action (especially navigating to a new page) when the user double clicks / activates a row. I have seen several solutions to this. But these don't work well enough for me. One problem is that my Grid is populated by a remote read. I know the grid is creating dom elements for each row. The best time to attach events to these events would be at that creation. Doing that in the row template function is not possible, since it only returns an html string, not dom elements. Attaching them via html may be possible but also feels hacky. I don't really want to populate the html with generated javascript code.

 At the moment I would probably try to monkey patch some internal grid function to achieve this....

3 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 10 Feb 2016, 07:37 AM

Hello Andreas,

You could attach the click handler via jQuery.
E.g.

$("#grid").on("dblclick", "tr[role='row']", function(){
    //custom logic
});

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Andreas
Top achievements
Rank 1
answered on 10 Feb 2016, 08:13 AM
Does that work for rows changing after this code is called? Because my main issue with the other solutions is that this attaching only works on the rows already rendered. If the REST call is coming back, or the app changes the dataset in another way, don't I have to attach the handlers again?     
0
Dimiter Madjarov
Telerik team
answered on 10 Feb 2016, 12:54 PM

Hello Andreas,

This is the standard jQuery way to attach handlers and will also work for dynamically rendered rows too, as long as the $("#grid") element is on the page.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Andreas
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Andreas
Top achievements
Rank 1
Share this question
or