Double Click event on Row of RadGridView

59 posts, 0 answers
  1. Ganesh Jagdale
    Ganesh Jagdale avatar
    69 posts
    Member since:
    Dec 2009

    Posted 27 Jan 2010 Link to this post

    Hi telerik,

    Is this possible to add Double click event on row of RadGridView?

    if it is posssible then pls give such example .. because there no such out of box  event available  for that..
    yes , it may be possible using "DependancyProperty"  but don't know exact.
     
    Pls help me out..

    Thanks,
     Ganesh
  2. Sebastjan Rataj
    Sebastjan Rataj avatar
    3 posts
    Member since:
    May 2008

    Posted 28 Jan 2010 Link to this post

    Hi

    I'm looking for the same thing. Any ideas?

    Regards, S
  3. Hyoung woo Lee
    Hyoung woo Lee avatar
    8 posts
    Member since:
    Dec 2009

    Posted 28 Jan 2010 Link to this post

    Hi

    Did you mean you are tring to attach event handler on gridview's row?

    Please look the code below :
      
    (this.GridView as RadGridView).AddHandler(  
    GridViewCell.MouseDoubleClickEvent,  
    new EventHandler<Telerik.Windows.RadRoutedEventArgs>(this.OnDoubleClick));  
     
     
    private void OnDoubleClick(object sender, Telerik.Windows.RadRoutedEventArgs e)  
    {  
            .....your logic    

    And you shoud add Telerik.window.controls.dll to your project.  hope this help

    Regards,
    Eum
  4. Sebastjan Rataj
    Sebastjan Rataj avatar
    3 posts
    Member since:
    May 2008

    Posted 28 Jan 2010 Link to this post

    Same solution is in another thread and it works.

    Thx.

    Regards S
  5. aviv ron
    aviv ron avatar
    10 posts
    Member since:
    Jan 2010

    Posted 17 Feb 2010 Link to this post

    i tried this solution but i am getting a compilation error:
    cannot convert from 'Telerik.Windows.RoutedEvent' to 'System.Windows.RoutedEvent'

    any ideas?

  6. Tom Wire
    Tom Wire avatar
    2 posts
    Member since:
    Mar 2010

    Posted 04 Jun 2010 Link to this post

    Getting the same error - anyone offer any pointers?
  7. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 04 Jun 2010 Link to this post

    Hello Tom Wire,

     Please find attached a solution that shows how to handle a double click event of GridViewRow.

    Best wishes,
    Yavor Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  8. Tom Wire
    Tom Wire avatar
    2 posts
    Member since:
    Mar 2010

    Posted 04 Jun 2010 Link to this post

    Great example, thanks Yavor!
  9. Mark Jakes
    Mark Jakes avatar
    27 posts
    Member since:
    Feb 2010

    Posted 05 Jun 2010 Link to this post

    Hi

    Thank you for your example.  I have implemented in my project and the double click works fine.   I use the DoubleClick event to open a RadWindow but I also have a context menu on the grid.

    My problem is that if a user single Left-clicks on a row and immediately right-clicks to get the context menu, the DoubleClick event gets fired.  This results in the context menu and the RadWindow being shown.

    This is not my desired action.  Is there any way of stopping this happening?  i.e. click on row, then a right click should just bring up the context menu.

    Thanks in advance

    Mark.

  10. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 07 Jun 2010 Link to this post

    Hello Mark Jakes,

     You might wish to implement a "custom" double click event like in the example I have posted, which tracks only the left mouse button, not both. Please inspect the solution and let me know if you need any help.

    Regards,
    Yavor Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  11. Angie
    Angie avatar
    33 posts
    Member since:
    Jul 2010

    Posted 29 Jul 2010 Link to this post

    RowActivated Event in GridView is the best fit for checking double click event

    myGridView.RowActivated+=
    new EventHandler<RowEventArgs>(myGridView_RowActivated);
  12. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 29 Jul 2010 Link to this post

    Hi Ravindranath,

     That is true most of the time - a double-click on the row does trigger the RowActivated event, but so does RadGridViewCommands.ActivateRow and a number of other actions, depending on user customization.

    Regards,
    Yavor Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. Mark Pearl
    Mark Pearl avatar
    3 posts
    Member since:
    Dec 2009

    Posted 16 Aug 2010 Link to this post

    Hi,

    Using the example project listed above, how can i differentiate between the double click on a GridViewRow and a GridViewHeaderRow?
  14. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 16 Aug 2010 Link to this post

    Hi Mark Pearl,

     There are two ways: check if the row is of type GridViewHeaderRow, GridViewNewRow or GridViewFooterRow and check if the row's Item property is null. Only GridViewRow contains a data item, so it's Item property will never be null.

    All the best,
    Yavor Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  15. troy
    troy avatar
    20 posts
    Member since:
    Jun 2008

    Posted 18 Aug 2010 Link to this post

    your example works pretty well.  the problem I see with it is that since you attached the event handler to the main page, if you click anywhere in the main page, it will fire the double click event.  I tried attaching the handler to the gridview which works better, but it still fires the double-click when I click on the group panel or scroll bar, etc.  Since there is always a selected row, I can't check the current row.  I'm looking for a solution short of having to add the handler on each row.

    Thanks!

    Troy
  16. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 18 Aug 2010 Link to this post

    Hello troy,

     That's the general idea of routed events in Silverlight and WPF - they climb up the visual tree so that in the end the control that handles the event gets hit whenever that event fires for any control below it in the visual tree. Handling LeftMouseButtonUp on your GridView or even UserControl is fine. You just have to check if the element in which the event originates is the one you need and only then take action.

    Besides, if you try to manually attach handlers to row objects, this will play merry hell with virtualization.

    All the best,
    Yavor Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  17. Miguel Rios
    Miguel Rios avatar
    21 posts
    Member since:
    Sep 2009

    Posted 03 Nov 2010 Link to this post

    Hi there,

    You've resolved all my problems...

    Thank you.
  18. Simon
    Simon avatar
    159 posts
    Member since:
    Sep 2010

    Posted 18 Dec 2010 Link to this post

    Hello Yavor,

    Your solution is working but I only see this as a workaround to the problem.

    If I want to use your code, I will have to duplicate it all over the place or build a wrapper user control around the RadGridView. 

    Why don't you add a Click and a DoubleClick event (with the clicked cell / row / column) to the RadGridView itself?  Click and DoubleClick are not extravagant features for a grid... in fact; they are built-in for almost every grid component since the last decade.
  19. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 20 Dec 2010 Link to this post

    Hi,

     Have you seen this demo?

    Best wishes,
    Vlad
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  20. Simon
    Simon avatar
    159 posts
    Member since:
    Sep 2010

    Posted 20 Dec 2010 Link to this post

    Yes I did but if when I tried to use the code as is, I came up with the problem mentionned above by 2 different users:

    cannot convert from 'Telerik.Windows.RoutedEvent' to 'System.Windows.RoutedEvent'

    Yavor solution is working but as I mentionned before, it's not perfect, esspecially when you need to reuse the code all over the place.
  21. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 20 Dec 2010 Link to this post

    Hi,

     As far as I can see no usage of RoutedEvent in this demo. Can you clarify? 

    All the best,
    Vlad
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  22. Simon
    Simon avatar
    159 posts
    Member since:
    Sep 2010

    Posted 20 Dec 2010 Link to this post

    In the Example.xaml.vb, the OnCellDoubleClick is refering to RadRoutedEventArgs. 

    Private Sub OnCellDoubleClick(sender As Object, args As RadRoutedEventArgs)


    However, the error is raised in this line of code:

    Me.RadGridView1.[AddHandler](GridViewCellBase.CellDoubleClickEvent, New EventHandler(Of RadRoutedEventArgs)(AddressOf OnCellDoubleClick), True)

    The error is on the first parameter (GridViewCellBase.CellDoubleClickEvent) wich is a System.Windows.RoutedEvent
  23. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 20 Dec 2010 Link to this post

    Hi,

    Have you copied the usings as well? 

    Greetings,
    Vlad
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  24. Simon
    Simon avatar
    159 posts
    Member since:
    Sep 2010

    Posted 20 Dec 2010 Link to this post

    Yes I did
  25. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 20 Dec 2010 Link to this post

    Hi,

     In this case everything should work as expected  - as on our example. 

    All the best,
    Vlad
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  26. Simon
    Simon avatar
    159 posts
    Member since:
    Sep 2010

    Posted 20 Dec 2010 Link to this post

    Hi Vlad,

    I did find out what was the problem.  A using statement is missing in the example source code:
    using Telerik.Windows;

    If you add this line, everything works as expected.

    An other option would be to call Telerik.Windows.DependencyObjectExtensions.AddHandler directly instead of using it as an extension.  That way, the using Telerik.Windows; line is not required. 
  27. Shrinivas
    Shrinivas avatar
    2 posts
    Member since:
    Dec 2010

    Posted 07 Jun 2011 Link to this post

    Is it possible to use this method to always get the value of a specific cell within the clicked row? I've been using something like this on the cell double click, but now have a requirement that clicking anywhere on the row should return the one cell's value:

            // handling the MouseDoubleClick event of the RadGridView
     
            void OnGridMouseDoubleClick(object sender, MouseButtonEventArgs e)
            {
                FrameworkElement originalSender = e.OriginalSource as FrameworkElement;
     
                object oTest = sender.GetType();
     
                if (originalSender != null)
                {
                    var cell = originalSender.ParentOfType<GridViewCell>();
     
                    if (cell != null && cell.Column.UniqueName == "CaseId")
                    {
    ...

    But, of course that limits clicks to the specific cell in order to get its value. Is there a way to get that value on a click on any cell in the row?



  28. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 08 Jun 2011 Link to this post

    Hello Shrinivas,

    You could try using CurrentCellChanged event which will be raised as you click on cells. 


    Best wishes,
    Milan
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  29. mirang
    mirang avatar
    115 posts
    Member since:
    Aug 2010

    Posted 04 Oct 2011 Link to this post

    The double click event as in the above example, does not work with the rowdetailstemplate. That is, I have a row details template and when i double click on that area the handler does not get execute. Any special case to be handled here ?
  30. Rob Ainscough
    Rob Ainscough avatar
    174 posts
    Member since:
    Jan 2010

    Posted 16 Nov 2011 Link to this post

    I've having the same issues with no "DoubleClick" event native to RadGridView with RowDetailsTemplate.  Seems odd why DoubleClick is NOT included as standard available event for the RadGridView??

    Is there any chance this is going to be added in the near future to a Q11 update?
Back to Top