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

Perform action on GroupHeader click

3 Answers 120 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David Dorst
Top achievements
Rank 1
David Dorst asked on 22 Sep 2010, 08:50 AM
Hello there,

I'm using a radGridView and the content comes via dataSource. The content is grouped by an expression, that's all fine so far. Now I need to perform (it would be really nice) an action if the user clicks on the GroupHeaderLine. It should be possible to do an action for the whole group (a menu should open then). Is this possible in Q2 2010?

Greetings

3 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 23 Sep 2010, 10:05 PM
Hello David,

I would like to ask you if you could elaborate on this, maybe provide a screenshot or some pieces of code explaining what you want to do, after that i will try to help you with your problem.

Best Regards,
Emanuel Varga
0
Accepted
Svett
Telerik team
answered on 24 Sep 2010, 04:36 PM
Hello David Dorst,

You can achieve that easily by creating a custom group row behavior where you can handle the keyboard and mouse input. 

public class MyGroupRowBehavior : GridGroupRowBehavior
{
    protected override bool OnMouseDownRight(MouseEventArgs e)
    {
        RadDropDownMenu menu = new RadDropDownMenu();
        menu.Items.Add(new RadMenuItem("MyMenuItem 1"));
        menu.Items.Add(new RadMenuItem("MyMenuItem 2"));
        menu.Show(this.GridViewElement.PointToScreen(e.Location));
        return true;
    }
}

You need to replace the default GridGroupRowBehavior with the a custom one:
BaseGridBehavior gridBehavior = this.radGridView1.GridBehavior as BaseGridBehavior;
gridBehavior.UnregisterBehavior(typeof(GridViewGroupRowInfo));
gridBehavior.RegisterBehavior(typeof(GridViewGroupRowInfo), new MyGroupRowBehavior());

I hope this helps.

Best wishes,
Svett
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
0
David Dorst
Top achievements
Rank 1
answered on 29 Sep 2010, 07:24 AM
This works really great :D

Thank you!
Tags
GridView
Asked by
David Dorst
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Svett
Telerik team
David Dorst
Top achievements
Rank 1
Share this question
or