We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Merge GridGroupingControl Column Header

Hello,
 
I need to group some column headers. On the samples i got stacked header could handle it, but i didn't get the point how to combine it with some column headers which are not grouped. I need to generate the column headers programmatically because appeared column are customized on database.
 
Please send me more documentation about how too set a Stacked header programmatically.
 
Thanks,
Salwa Omar

8 Replies

ES Eswari S Syncfusion Team June 25, 2012 11:18 AM UTC

Hi Salwa,

Thank you for using Syncfusion products.

Your requirement of stacked headers can be achieved by adding visible columns to the GridStackedHeaderRowDescriptor. Please refer to the following code snippets: 
protected void Page_Load(object sender, EventArgs e)    {
        if (!IsPostBack)
        {                                                                                                                
            this.GridGroupingControl1.DataSource = GetData(); 
            GridStackedHeaderRowDescriptor rowDescriptor = new GridStackedHeaderRowDescriptor("row1"); // create row for stacked headers
 
            GridStackedHeaderDescriptor gshd = new GridStackedHeaderDescriptor("StackedHeader 1");  // add visible columns to the stacked header descriptor
            gshd.VisibleColumns.Add("Code");
            gshd.VisibleColumns.Add("Name");
            gshd.VisibleColumns.Add("Due");
            gshd.VisibleColumns.Add("Not Due");
            rowDescriptor.Headers.Add(gshd); 
            gshd = new GridStackedHeaderDescriptor("StackedHeader 2");
            gshd.VisibleColumns.Add("Total");
            gshd.VisibleColumns.Add("31 To 60");
            gshd.VisibleColumns.Add("91 To 120");
            rowDescriptor.Headers.Add(gshd);
            this.GridGroupingControl1.TableDescriptor.StackedHeaderRows.Add(rowDescriptor); // add created row descriptor into StackedHeaderRows
        }
    } 

For your convenience , we have prepared the sample and the same can be downloaded from the following link:

http://www.syncfusion.com/downloads/Support/DirectTrac/86129/StackedHeader-1120612589.zip

Also ,please check with the following online sample link:

http://asp.syncfusion.com/demos/ui/gridgrouping/Columns%20and%20Rows/StackedHeader/cs/StackedHeader.aspx

Please let us know if you need any further assistance.

Regards,

Eswari.S



SO Salwa Omar June 25, 2012 08:28 PM UTC

Hello Eswari,
 
Thanks for your quick response. I still didn't find how to combine between stacked header columns and usual column headers.
How if i just want to group some column headers?
For example, there are 3 columns: Customer ID, First Name, Last Name.
I just need to group column header of First Name and Last Name as Customer Name. That mean Customer ID will not refer to any Stacked header.
How to define GGC columns based on that case.
 
Best Regards,
Salwa Omar


ES Eswari S Syncfusion Team June 26, 2012 12:19 PM UTC

Hi Salwa,                 

Thanks for the update.

Query #1: I just need to group column header of First Name and Last Name as Customer Name. That mean Customer ID will not refer to any Stacked header.

We can achieve your requirement by adding only required columns to the stacked header rows. Please refer to the following code snippets:

            GridStackedHeaderRowDescriptor rowDescriptor = new GridStackedHeaderRowDescriptor("row1");

            GridStackedHeaderDescriptor gshd1 = new GridStackedHeaderDescriptor("Customer Name");

            gshd1.VisibleColumns.Add("Name"); 

            gshd1.VisibleColumns.Add("Code");                                        //             Customer Name stacked header

              

            rowDescriptor.Headers.Add(gshd1);

 

            GridStackedHeaderDescriptor gshd2  = new GridStackedHeaderDescriptor("Due");

            gshd2.VisibleColumns.Add("Due");

            gshd2.VisibleColumns.Add("Not Due");                                 //            Due stacked header

 

            rowDescriptor.Headers.Add(gshd2);

            GridStackedHeaderDescriptor gshd3 = new GridStackedHeaderDescriptor("Code 31-120");

            gshd3.VisibleColumns.Add("91 To 120");            

            gshd3.VisibleColumns.Add("31 To 60");                                  //            Code stacked header

        

            rowDescriptor.Headers.Add(gshd3);

            this.GridGroupingControl1.TableDescriptor.StackedHeaderRows.Add(rowDescriptor);

                            

And here Total Column is not added to any one of the stacked headers ,so it will be added as like normal column header. Please check with the following screen shot:

 

For your convenience ,we have prepared the sample and the same can be downloaded from the following link:

http://www.syncfusion.com/downloads/Support/DirectTrac/95950/StackedHeader-1906766378.zip

 Also could please give more information about your requirement. Whether you want to merge First Name and last name column headers or else you need to merge two columns (first name and last name) as single merged column ,could you please clarify this so that we can analyze based on that and provide you the better solution.

Please let us know if you have any queries.

Regards,

Eswari.S

                                                                                                                                            

 

                                                                



SO Salwa Omar June 27, 2012 01:42 AM UTC

Hello Eswari,
 
The requirment to merge rows of column header which not belong to stacked header. Please refer to colum Total on the sample below:
 

Customer Name

Due

Code 31-120

Total

Code

Name

Due

Not Due

31 - 60

91 - 120

 
 
Thanks,
Salwa Omar


ES Eswari S Syncfusion Team June 27, 2012 11:58 AM UTC

Hi Salwa,

Thanks for your patience.

Currently we have support for Merging column header with Stacked column header.  The ‘Column header merging with stacked column header’ has been confirmed as a usability feature and has been logged as a feature report . We will implement this feature in any of our upcoming releases. We usually have an interval of at least three months between releases. The feature implementation would also greatly depend on the factors such as product design, code compatibility and complexity. We will update you when this feature has been implemented.

However, we do not provide confidential information and patches in the general forum, so could you please create a new incident such that we can easily follow up with the feature.

Let us know if you have any other queries.                                     

Regards,

Eswari.S                                                                                                                                                         

 



SO Salwa Omar June 28, 2012 09:51 AM UTC

Hello Eswari,
1. Is it possible to locate stacked header columns after non-stacked header column?
StackedHeader1 StackedHeader2
Column1 Column2 Column3 Column4 Column5 Column6
           
           

2. How to put stacked header on child grid?
  Column1 Column2
-            
   
  ChildStackedHeader  
    Column1 Column2 Column3  
           
   
             

3. Could we add freeze header column on child grid?
  Column1 Column2
-            
   
  ChildStackedHeader  
    Column1 Column2 Column3    
             
           
         
   
             

4. Could we add template field column on child grid to put hyperlink control?
  Column1 Column2
-            
   
  ChildStackedHeader  
    Column1 Column2 Column3  
    hyperlink      
   
             

5. What's the different between passThruGroupingDataSource and PassThroughGrouping? I need example how to implement both of them without LINQ.
 
Regards,
Salwa Omar


SO Salwa Omar July 10, 2012 10:30 AM UTC

Hello Eswari,
 
Could you help to answer my questions? Could Syncfusion Essential Grid accomodate my requirement as described on my previous question?


MS Mohanraj S Syncfusion Team August 27, 2012 12:35 PM UTC

Hi Salwa,

 

Thanks for your update.

 

[Query:1] Is it possible to locate stacked header columns after non-stacked header column?

It is not possible to locate stacked header columns after non-stacked header column. Currently we do not provide 'Support for stacked header columns after non-stacked header column'. This has been confirmed as a Feature Request. We will implement this feature in our forthcoming new version releases or service pack releases.

We will update you when this feature has been implemented.

                               

[Query:2] How to put stacked header on child grid?

Your requirement "stacked header on child grid" can be achieved through c# code.

Please refer the following code snippet.

if (!IsPostBack)

        {

            DataTable parentTable = GetParentTable();

            DataTable childTable = GetChildTable();

 

            GridRelationDescriptor parentToChildRelationDescriptor = new GridRelationDescriptor();

            parentToChildRelationDescriptor.ChildTableName = "MyChildTable";

            parentToChildRelationDescriptor.RelationKind = RelationKind.RelatedMasterDetails;

            parentToChildRelationDescriptor.RelationKeys.Add("Code", "Code");

 

            GridStackedHeaderRowDescriptor rowDescriptor = new GridStackedHeaderRowDescriptor("row1");

            GridStackedHeaderDescriptor gshd1 = new GridStackedHeaderDescriptor("Client Details");

            gshd1.VisibleColumns.Add("Code");

            gshd1.VisibleColumns.Add("ClientName");

            rowDescriptor.Headers.Add(gshd1);

 

            GridStackedHeaderDescriptor gshd2 = new GridStackedHeaderDescriptor("Order Details");

            gshd2.VisibleColumns.Add("Details");

            gshd2.VisibleColumns.Add("City");

            rowDescriptor.Headers.Add(gshd2);

 

            parentToChildRelationDescriptor.ChildTableDescriptor.StackedHeaderRows.Add(rowDescriptor);

 

            parentToChildRelationDescriptor.ChildTableDescriptor.AllowEdit = false;

 

            GridGroupingControl1.TableDescriptor.Relations.Add(parentToChildRelationDescriptor);

 

            this.GridGroupingControl1.Engine.SourceListSet.Add("MyParentTable", parentTable);

            this.GridGroupingControl1.Engine.SourceListSet.Add("MyChildTable", childTable);

 

            this.GridGroupingControl1.DataMember = "DefaultView";

            this.GridGroupingControl1.DataSource = parentTable;

        }

Please refer to the below link to download the sample application.

ChildGridStackedHeader.zip

 

[Query:3] Could we add freeze header column on child grid?

Currently we do not provide 'Support for freeze header column on child grid'. This has been confirmed as a Feature Request.We will implement this feature in our forthcoming new version releases or service pack releases.

We will update you when this feature has been implemented.

 

[Query:4] Could we add template field column on child grid to put hyperlink control?

Your requirement "template field column on child grid" can be achieved through c# code.

Please refer the following code snippet.

protected void Page_Load(object sender, EventArgs e)

{

this.GridGroupingControl1.QueryCellStyleInfo +=new GridTableCellStyleInfoEventHandler(GridGroupingControl1_QueryCellStyleInfo);

}

protected void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)

    {

        if (e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell)

        {

            if (e.TableCellIdentity.Column.MappingName == "City")

            {

                HyperLink hlink = new HyperLink();

                hlink.Text = "London";

                hlink.NavigateUrl = "http://google.com/search?q=London";

                TemplateClass mytemp = new TemplateClass(hlink);

                e.TableCellIdentity.Column.ItemTemplate = mytemp;

            }

        }

    }

    public class TemplateClass : ITemplate

    {

        private Control m_ctrlChildControl = null;

        public TemplateClass(Control ctrlChildControl)

        {

            m_ctrlChildControl = ctrlChildControl;

        }

        public void InstantiateIn(Control container)

        {

            container.Controls.Add(m_ctrlChildControl);

        }

    }

Please refer to the below link to download the sample application.

TemplateChildGrid.zip

 

[Query:5]  What's the different between passThruGroupingDataSource and PassThroughGrouping? I need example how to implement both of them without LINQ.

There is no difference between passThruGroupingDataSource and PassThroughGrouping. Both are same. It is not possible to implement passThruGroupingDataSource without LINQ.

Please refer the below link for passThruGroupingDataSource minimum requirements.

http://help.syncfusion.com/UG/User%20Interface/ASP.NET/Grid/documents/44passthrugroupingdatasource.htm

 

Please let us know if you have any concerns.

                                                                               

Regards,

Mohanraj

 


Loader.
Live Chat Icon For mobile
Up arrow icon