ColumnGroup Problem

3 posts, 0 answers
  1. Pete
    Pete avatar
    4 posts
    Member since:
    Sep 2011

    Posted 30 Sep 2015 Link to this post

    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. Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 01 Oct 2015 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Pete
    Pete avatar
    4 posts
    Member since:
    Sep 2011

    Posted 01 Oct 2015 in reply to Dimitar Link to this post

    That fixed it.  Thank you
Back to Top