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

Virtual Mode and Groups

1 Answer 73 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Werner Depenbrock
Top achievements
Rank 1
Werner Depenbrock asked on 08 Apr 2009, 07:25 AM
Hello,

I have a RadGridView generated with many rows. This grid is in virtual mode. Now I want to generate groups. The GroupByExpression property doesn't work. How can I generate groups in virtual mode?

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 13 Apr 2009, 08:55 AM
Hello Werner Depenbrock,

Sorry for the delay of my answer.

You can use the new virtual grouping functionality in RadGridView. When grid is in virtual mode you can handle also the DataGroupNeeded event:

public partial class VirtualForm : Form 
    public VirtualForm() 
    { 
        InitializeComponent(); 
    } 
 
    Random rand = new Random(1000); 
    protected override void OnLoad(EventArgs e) 
    { 
        base.OnLoad(e); 
 
        this.radGridView1.ColumnCount = 10; 
        this.radGridView1.RowCount = 100; 
 
        for (int i = 0; i < this.radGridView1.ColumnCount; i++) 
        { 
            this.radGridView1.Columns[i].HeaderText = this.radGridView1.Columns[i].UniqueName; 
        } 
 
        this.radGridView1.MasterGridViewTemplate.BestFitColumns(); 
    } 
 
    private void radGridView1_CellValueNeeded(object sender, Telerik.WinControls.UI.GridViewCellValueEventArgs e) 
    { 
        e.Value = rand.Next(); 
    } 
 
    private void radGridView1_DataGroupNeeded(object sender, Telerik.WinControls.UI.GridViewDataGroupEventArgs e) 
    { 
        if (e.Expression.GroupByFields[0].FieldName == "Column5"
        { 
            e.GroupCount = 5; 
 
            e.HeaderText[0] = "TestGroup1"
            e.RowCount[0] = 20; 
 
            e.HeaderText[1] = "TestGroup2"
            e.RowCount[1] = 20; 
 
            e.HeaderText[2] = "TestGroup3"
            e.RowCount[2] = 20; 
 
            e.HeaderText[3] = "TestGroup4"
            e.RowCount[3] = 20; 
 
            e.HeaderText[4] = "TestGroup5"
            e.RowCount[4] = 20; 
        } 
    } 

Do not hesitate to write me back if you have further questions.

Regards,
Julian Benkov
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Werner Depenbrock
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or