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

RadGridView GroupRow - click event

3 Answers 104 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Florin
Top achievements
Rank 1
Florin asked on 05 Oct 2011, 09:04 AM
Hello,

It is possible to add an event on groupRow ? I want - when i click on groupRow - to stop collapsing/expanding and to access some how the information stored groupRow and on double click event to have his normal functionality.

So far I have managed to add an event, but I don't have access to the object in groupRow. For this i use the code:
this.AddHandler(GridViewGroupRow.MouseLeftButtonUpEvent, new MouseButtonEventHandler(this.GridViewRow_OnMouseLeftButtonUp), true);

Best wishes,
Florin

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 10 Oct 2011, 09:34 AM
Hi Florin,

Would you please shed some more light on your requirements? What do you mean by mentioning "information stored in group row"? In case you have visual elements in mind, you can access them by searching for them in the visual three. For instance, since the default visual element displayed in GridViewGroupRow is a TextBlock, you can access it like this:
clubsGrid.ChildrenOfType<GridViewGroupRow>().First().ChildrenOfType<TextBlock>().First();
 The approach is similar if you have defined a GroupRowTemplate.

Greetings,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Florin
Top achievements
Rank 1
answered on 11 Oct 2011, 09:45 AM
Hello,

I mean, if i had a RadGridView with three columns ID, LastName and FirstName and I drag the column LastName into group section, the RadGridView component make a group by LastName. So when i click on the grouped row (lastName) i want the behavior described on first post. On click event i want to take the ID.

Best wishes,
Florin
0
Maya
Telerik team
answered on 14 Oct 2011, 08:44 AM
Hi Florin,

You can get the information for the group row by getting its GroupViewModel and examining its properties. For example:
this.AddHandler(GridViewGroupRow.MouseLeftButtonUpEvent, new MouseButtonEventHandler(OnMouseLeftButtonUp), true);
        
         
        private void OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            FrameworkElement clickedElement = e.OriginalSource as FrameworkElement;
            GridViewGroupRow groupRow = clickedElement.ParentOfType<GridViewGroupRow>();
            if(groupRow != null)
            {
                GroupViewModel groupViewModel = groupRow.GroupViewModel as GroupViewModel;
            }
        }

Considering the double click functionality, you could try to implement the idea illustrated in this forum thread (you can use the DoubleClickOnRow-Behavior.zip project) . In your case, however, you will work with GridViewGroupRow, not GridViewRow.


All the best,
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
GridView
Asked by
Florin
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Florin
Top achievements
Rank 1
Maya
Telerik team
Share this question
or