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

ColumnGroup Problem

2 Answers 74 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Pete
Top achievements
Rank 1
Pete asked on 30 Sep 2015, 08:24 PM

I have a problem with the way ColumnGrouping is handling a GridViewTextBoxColumn.  I have recreated the problem in a very simple code snippet.  I am attaching a screen image of how it is rendered and the code that populates the table.

What am I doing wrong?

radGridView1.Visible = false;
radGridView1.Columns.Clear();
radGridView1.Rows.Clear();
radGridView1.SummaryRowsTop.Clear();
radGridView1.Refresh();
//radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
// Handle Planning Group definitions if provided.
ColumnGroupsViewDefinition ColView = new ColumnGroupsViewDefinition();
ColView.ColumnGroups.Add(new GridViewColumnGroup("SYSTEM"));
ColView.ColumnGroups.Add(new GridViewColumnGroup("DETAILS"));
ColView.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
ColView.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
radGridView1.TableElement.BeginUpdate();
GridViewTextBoxColumn gt = new GridViewTextBoxColumn("System");
//gt.MaxLength = 40;
gt.AutoSizeMode = BestFitColumnMode.None;
radGridView1.MasterTemplate.Columns.Add(gt);
ColView.ColumnGroups[0].Rows[0].Columns.Add(radGridView1.Columns["System"]);
for (int x=1; x<10; x++)
{
radGridView1.MasterTemplate.Columns.Add(new GridViewDecimalColumn(x.ToString()));
ColView.ColumnGroups[1].Rows[0].Columns.Add(radGridView1.Columns[x.ToString()]);
}
radGridView1.ViewDefinition = ColView;
// Add data rows
for (int y=1; y<20; y++)
{
// Populate the columns for this system
object[] columns = new object[10]; // Allocate a new array
columns[0] = "System"+y.ToString();
for (int c=1; c<10; c++)
{
columns[c] = Convert.ToDecimal(y*c);
}
radGridView1.Rows.Add(columns);
}
// Done populating grid
radGridView1.TableElement.EndUpdate();
radGridView1.Columns[0].IsPinned = true;
radGridView1.Columns[0].PinPosition = PinnedColumnPosition.Left;
radGridView1.Refresh();
radGridView1.Visible = true; 

 

 

 

2 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 01 Oct 2015, 10:41 AM
Hello Pete,

Thank you for writing.

You can only pin top level groups when ColumnGroupsViewDefinition is used. In your case, you can pin the first group like this:
ColumnGroupsViewDefinition colView = new ColumnGroupsViewDefinition();
colView.ColumnGroups.Add(new GridViewColumnGroup("SYSTEM") { IsPinned = true });
colView.ColumnGroups.Add(new GridViewColumnGroup("DETAILS"));
colView.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
colView.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
 
GridViewTextBoxColumn gt = new GridViewTextBoxColumn("System");
 
gt.AutoSizeMode = BestFitColumnMode.None;
radGridView1.MasterTemplate.Columns.Add(gt);
 
colView.ColumnGroups[0].Rows[0].Columns.Add(radGridView1.Columns["System"]);
 
for (int x = 1; x < 10; x++)
{
    radGridView1.MasterTemplate.Columns.Add(new GridViewDecimalColumn(x.ToString()));
    colView.ColumnGroups[1].Rows[0].Columns.Add(radGridView1.Columns[x.ToString()]);
}
radGridView1.ViewDefinition = colView;
 
// Add data rows
for (int y = 1; y < 20; y++)
{
    // Populate the columns for this system
    object[] columns = new object[10]; // Allocate a new array
    columns[0] = "System" + y.ToString();
    for (int c = 1; c < 10; c++)
    {
        columns[c] = Convert.ToDecimal(y * c);
    }
    radGridView1.Rows.Add(columns);
}

Let me know if you have additional questions.
 
Regards,
Dimitar
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Pete
Top achievements
Rank 1
answered on 01 Oct 2015, 01:40 PM
That fixed it.  Thank you
Tags
GridView
Asked by
Pete
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Pete
Top achievements
Rank 1
Share this question
or