Row doubleclicking (again)

4 posts, 0 answers
  1. Andreas
    Andreas avatar
    3 posts
    Member since:
    Jan 2016

    Posted 07 Feb 2016 Link to this post

    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....

  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2312 posts

    Posted 10 Feb 2016 Link to this post

    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!
     
  3. Andreas
    Andreas avatar
    3 posts
    Member since:
    Jan 2016

    Posted 10 Feb 2016 in reply to Dimiter Madjarov Link to this post

    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?     
  4. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2312 posts

    Posted 10 Feb 2016 Link to this post

    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!
     
Back to Top