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

Nested GridViews double click issue

2 Answers 93 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 15 Jan 2015, 12:37 AM
Hi,
I am having an interesting issue with nested GridViews using row details.
I need to be able to double click on rows in both the child and parent GridView and handle them differently.
But there seems to be an odd behavior where when I double click on the child row the MouseDoubleClickEvent gets raised on the child row first, then a different MouseDoubleClickEvent gets raised on the parent row. Event if I set the first event to being handled a separate event is raised on the parent row.
The event handlers are being added on the RowLoaded event for both the child and parent GridViews.



Kind Regards,

Ryan

2 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 15 Jan 2015, 01:04 PM
Hi Ryan,

Indeed, this is a routed event and it will be raised for both child and parent rows. You can distinguish which one actually raised the exception through the information coming with e.Source and e.OriginalSource. This is how you can differentiate both the cases.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Ryan
Top achievements
Rank 1
answered on 16 Jan 2015, 01:15 AM
Hi Dimitrina,
Thanks for the reply, changing from a RowLoaded event to using the CellDoubleClickEvent and using the original source I was able to tell the difference, like below.

GridView.AddHandler(GridViewCellBase.CellDoubleClickEvent, new EventHandler<RadRoutedEventArgs>(OnCellDoubleClick), true);



private void OnCellDoubleClick(object sender, RadRoutedEventArgs e)
{
    if (e.OriginalSource is GridViewCell)
    {
        var cell = e.OriginalSource as GridViewCell;
 
        object item = cell.ParentRow.Item;
        if (item is TemplateSectionWrapper)
        {
                var wrapper = item as TemplateSectionWrapper;
                TemplateSectionEditWindow window = new TemplateSectionEditWindow(context, wrapper.Section);
        }
        else if (item is TemplateSectionInventoryWrapper)
        {
                var window = new TemplateInventoryEditWindow(context, ViewModel.DeliveryGroups.ToList(), item as TemplateSectionInventoryWrapper);
        }
    }
}

Thanks for your help,

Ryan
Tags
GridView
Asked by
Ryan
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or