RadGridView GroupRow - click event

4 posts, 0 answers
  1. Florin
    Florin avatar
    5 posts
    Member since:
    Jul 2011

    Posted 05 Oct 2011 Link to this post

    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
  2. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1217 posts

    Posted 10 Oct 2011 Link to this post

    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 >>
  3. Florin
    Florin avatar
    5 posts
    Member since:
    Jul 2011

    Posted 11 Oct 2011 Link to this post

    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
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 14 Oct 2011 Link to this post

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