summarize Column Headers

9 posts, 0 answers
  1. Axel
    Axel avatar
    12 posts
    Member since:
    May 2011

    Posted 05 Oct 2011 Link to this post

    Hello,
    I want "four column headings" Merge to "1" header line.
    is that possible?
  2. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 05 Oct 2011 Link to this post

    Hello Axel,

    If you are refering to the main headers please take a look at this help article.

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Axel
    Axel avatar
    12 posts
    Member since:
    May 2011

    Posted 06 Oct 2011 Link to this post

    Hello,
    Thanks for the tip.
    But I still have a problem.

    I bound the DataSource of the grid to a DataTable.
    Data is displayed.

    Once the datasource is set.
    I use the following code:

     

     

    ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();

     

     

    view.ColumnGroups.Add(new GridViewColumnGroup("Date"));

     

    view.ColumnGroups[0].Groups.Add(new GridViewColumnGroup("01"));

     

    view.ColumnGroups[0].Groups.Add(new GridViewColumnGroup("02"));

     

    RadGV.ViewDefinition = view;


    Then the grid shows nothing more.
    Why?

    Can it be that there is a view definition, already?
    (set by the Data Source)
  5. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 06 Oct 2011 Link to this post

    Hello Axel,

    Yes, you are correct, if you are using a custom view definition you should define all the columns you want to display there.

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP
  6. Axel
    Axel avatar
    12 posts
    Member since:
    May 2011

    Posted 06 Oct 2011 Link to this post

    Hello,
    Can you give me an example?
    This is my code:


    private void button1_Click(object sender, EventArgs e)
           {
               
               DataTable dataSource = new DataTable("Test");
     
               dataSource.Columns.Add("ID", typeof(int));
               dataSource.Columns.Add("ParentID", typeof(int));
               dataSource.Columns.Add("Art", typeof(string));
               dataSource.Columns.Add("WC", typeof(string));
               dataSource.Columns.Add("SP2", typeof(string));
               dataSource.Columns.Add("SP3", typeof(string));
               dataSource.Columns.Add("01", typeof(string));
               dataSource.Columns.Add("02", typeof(string));
                
               int LfdNr = 1;
               int ParentNr;
               ///     ID / ParentID / Art / WC / area / Status Color / Status desc;
               dataSource.Rows.Add(LfdNr, null, "WC", "T01", -16711936, "Normal");
               ParentNr = LfdNr;
               LfdNr += 1;
               dataSource.Rows.Add(LfdNr, ParentNr , "A", "Test", -16711936, "Normal");
               LfdNr += 1;
               dataSource.Rows.Add(LfdNr, null, "WC", "T02", -16711936, "Normal");
               LfdNr += 1;
               dataSource.Rows.Add(LfdNr, null, "WC", "T03", -16711936, "Normal");
               LfdNr += 1;
     
               radGridView1.DataSource = dataSource;
     
               this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "ID", "ParentID");
               this.radGridView1.Columns["ID"].IsVisible = false;
               this.radGridView1.Columns["ParentID"].IsVisible = false;
     
               this.radGridView1.Columns["Art"].IsVisible = false;
     
               //ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
               //view.ColumnGroups.Add(new GridViewColumnGroup("Date"));
               //view.ColumnGroups[0].Groups.Add(new GridViewColumnGroup("01"));
               //view.ColumnGroups[0].Groups.Add(new GridViewColumnGroup("02"));
               //radGridView1.ViewDefinition = view;
     
           }
  7. Emanuel Varga
    Emanuel Varga avatar
    1336 posts
    Member since:
    May 2010

    Posted 06 Oct 2011 Link to this post

    Hello again,

    To show the main Date Header and with 01 and 02 under it change your code like so:
    ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
     
    var dateGroup = new GridViewColumnGroup("Date");
    view.ColumnGroups.Add(dateGroup);
    dateGroup.Rows.Add(new GridViewColumnGroupRow());
    dateGroup.Rows[0].Columns.Add(radGridView1.Columns["01"]);
    dateGroup.Rows[0].Columns.Add(radGridView1.Columns["02"]);
    radGridView1.ViewDefinition = view;

    Hope this helps, if you have any other questions or comments, please let me know,

    Best Regards,
    Emanuel Varga

    Telerik WinForms MVP
  8. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 07 Oct 2011 Link to this post

    Hello Axel,

    Thank you for writing.

    Emanuel's solution should cover your case. Remember to mark it as an answer, so other can find the solution to their question quicker. If this is not what you want or you have other questions, feel free to write again and we will try to help the best way we can.

    Best wishes,
    Ivan Petrov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  9. Axel
    Axel avatar
    12 posts
    Member since:
    May 2011

    Posted 12 Oct 2011 Link to this post

    Hello,
    Now I have a problem.


    By this code:
    DataTable dataSource = new DataTable("Test");
     
               dataSource.Columns.Add("ID", typeof(int));
               dataSource.Columns.Add("ParentID", typeof(int));
               dataSource.Columns.Add("Art", typeof(string));
               dataSource.Columns.Add("WC", typeof(string));
               dataSource.Columns.Add("SP2", typeof(string));
               dataSource.Columns.Add("SP3", typeof(string));
               dataSource.Columns.Add("01", typeof(string));
               dataSource.Columns.Add("02", typeof(string));
                
               int LfdNr = 1;
               int ParentNr;
               ///     ID / ParentID / Art / WC / area / Status Color / Status desc;
               dataSource.Rows.Add(LfdNr, null, "WC", "T01", -16711936, "Normal");
               ParentNr = LfdNr;
               LfdNr += 1;
               dataSource.Rows.Add(LfdNr, ParentNr , "A", "Test", -16711936, "Normal");
               LfdNr += 1;
               dataSource.Rows.Add(LfdNr, null, "WC", "T02", -16711936, "Normal");
               LfdNr += 1;
               dataSource.Rows.Add(LfdNr, null, "WC", "T03", -16711936, "Normal");
               LfdNr += 1;
     
               radGridView1.DataSource = dataSource;
     
         
     
               ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
               var wcGroup = new GridViewColumnGroup("WC");
               var dateGroup = new GridViewColumnGroup("Date");
               view.ColumnGroups.Add(wcGroup);
               view.ColumnGroups.Add(dateGroup);
             
               dateGroup.Rows.Add(new GridViewColumnGroupRow());
               dateGroup.Rows[0].Columns.Add(radGridView1.Columns["01"]);
               dateGroup.Rows[0].Columns.Add(radGridView1.Columns["02"]);
                
               wcGroup.Rows.Add(new GridViewColumnGroupRow());
               wcGroup.Rows[0].Columns.Add(radGridView1.Columns["ID"]);
               wcGroup.Rows[0].Columns.Add(radGridView1.Columns["ParentID"]);
               wcGroup.Rows[0].Columns.Add(radGridView1.Columns["WC"]);
               wcGroup.Rows[0].Columns.Add(radGridView1.Columns["Art"]);
               wcGroup.Rows[0].Columns.Add(radGridView1.Columns["SP2"]);
               wcGroup.Rows[0].Columns.Add(radGridView1.Columns["SP3"]);
     
               radGridView1.ViewDefinition = view;
     
               this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "ID", "ParentID");



     When grouping, he shows no sign of plus more.

    Grouping I do with this code:
    this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "ID", "ParentID");
           
  10. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 17 Oct 2011 Link to this post

    Hi Axel,

    Thank you for writing back.

    Creating a self-reference hierarchy in grid is not the same as grouping. For a self-reference grid you need a data source with hierarchical data in it. For your case where the data source is a flat table you should use a group descriptor. To make the descriptor work, you just have to add it to the RadGridView GroupDescriptors collection. Just substitute the following line of your code:

    this.radGridView1.Relations.AddSelfReference(this.radGridView1.MasterTemplate, "ID", "ParentID");
    with this one:
    this.radGridView1.GroupDescriptors.Add(new GroupDescriptor("ParentID"));

    I hope this will help you. if you have further questions, I would be glad to help. Greetings,
    Ivan Petrov
    the Telerik team

    Q2’11 SP1 of RadControls for WinForms is available for download (see what's new); also available is the Q3'11 Roadmap for Telerik Windows Forms controls.

Back to Top
UI for WinForms is Visual Studio 2017 Ready