BoldDeskPremium customer service software with affordable pricing: $10 for 3 agents. Try it for free.
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:
Please let us know if you need any
further assistance.
Regards,
Eswari.S
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
Customer Name | Due | Code 31-120 |
Total |
|||
Code | Name | Due | Not Due | 31 - 60 | 91 - 120 |
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
StackedHeader1 | StackedHeader2 | ||||
Column1 | Column2 | Column3 | Column4 | Column5 | Column6 |
Column1 | Column2 | |||||
- | ||||||
ChildStackedHeader | ||||||
Column1 | Column2 | Column3 | ||||
Column1 | Column2 | |||||
- | ||||||
ChildStackedHeader | ↑ | |||||
Column1 | Column2 | Column3 | ||||
↓ | ||||||
Column1 | Column2 | |||||
- | ||||||
ChildStackedHeader | ||||||
Column1 | Column2 | Column3 | ||||
hyperlink | ||||||
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.
[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.
[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.
Please let us know if you have any concerns.
Regards,
Mohanraj