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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Need to merge the records in Child View

Thread ID:

Created:

Updated:

Platform:

Replies:

132276 Aug 24,2017 05:20 AM UTC Aug 28,2017 12:37 PM UTC WinForms 3
loading
Tags: GridGroupingControl
Dhairya Joshi
Asked On August 24, 2017 05:20 AM UTC

Hello Experts, Hope you are doing well !

I need help with GridGroupControl. I have two tables through which the data is getting populated into Grid
1) InvoiceMaster (InvoiceID,custID,totalAmount,discount,netamount,payment)
2) InvoiceSubDetails(invoiceID,itemname,itemprice)

As I've joined the tables by invoice ID and populated the data. I performed the grouping by Invoice ID so the output looks like a demo in attachments please check that as well.



Note : Please check the screen shot so that I can explain in details (Marked as RED)
My Few Requirements are as follow : 
1) I want to remove that top header which says 6 Items.
2) I want to remove that new line * comes up.
3) Is there any way I can show only ItemName and ItemPrice in the child Notes Ex If i Expand the InvoicID i can only display Itemname and itemprice
4) As you can see it shows invoiceid, custid, totalamount, discount, NetAmount,payment for each row by invoiceID. Can i merge them so that it can show only once?
5) I need a way to export data into Excel. I can easily do that by exporting DataTable but it will not be formatted as I want it as looks like in GGC.

Please it will be great help to get this done.
Thanks in advance,

Piruthiviraj Malaimelraj [Syncfusion]
Replied On August 25, 2017 10:17 AM UTC

Hi Dhairya, 

Thanks for your interest in Syncfusion products. 

Query 
Response 
 I want to remove that top header which says 6 Items. 
You can hide the caption text by using ShowCaption property of grid. 
 
Code snippet: 
//To disable caption for parent table 
this.gridGroupingControl1.TopLevelGroupOptions.ShowCaption = false; 
//To disable caption for nested tables 
this.gridGroupingControl1.NestedTableGroupOptions.ShowCaption = false; 
I want to remove that new line * comes up. 
The ShowAddNewRecordBeforeDetails property can be used to remove the AddNewRecordRow. 
 
Code snippet: 
//For parent table 
this.gridGroupingControl1.TopLevelGroupOptions.ShowAddNewRecordBeforeDetails = false; 
//For nested table 
this.gridGroupingControl1.NestedTableGroupOptions.ShowAddNewRecordBeforeDetails = false; 
Is there any way I can show only ItemName and ItemPrice in the child Notes Ex If i Expand the InvoicID i can only display Itemname and itemprice 
We have checked that given screenshot, it seems like the records are grouped by “InvoiceId” column.  

If the parent table and child table are related by unique column, the child table will show its columns only. We are little bit unclear about the way of adding relations between two tables in your sample project. Here we have provided the simple sample with “RelatedMasterDetails” relation. 

Code snippet: 
this.gridGroupingControl1.Engine.SourceListSet.Add("InvoiceMaster", parentTable); 
this.gridGroupingControl1.Engine.SourceListSet.Add("InvoiceSubDetails", childTable); 
 
GridRelationDescriptor rd = new GridRelationDescriptor(); 
rd.ChildTableName = "InvoiceSubDetails"; 
rd.RelationKind = Syncfusion.Grouping.RelationKind.RelatedMasterDetails; 
rd.RelationKeys.Add("InvoiceID", "invoiceID"); 
 
this.gridGroupingControl1.TableDescriptor.Relations.Add(rd); 
 
 

UG link: 

Please let us know if we missed anything from this scenario. 
 As you can see it shows invoiceid, custid, totalamount, discount, NetAmount,payment for each row by invoiceID. Can i merge them so that it can show only once? 
You can merge the cells which having same values in rows of a column and in columns of a row. Please refer to the below code snippet, 

Code snippet 
//Merging in ParentTable 
this.gridGroupingControl1.TableDescriptor.Appearance.AnyRecordFieldCell.MergeCell = GridMergeCellDirection.Both; 
this.gridGroupingControl1.TableModel.Options.MergeCellsMode = GridMergeCellsMode.OnDemandCalculation | GridMergeCellsMode.MergeRowsInColumn;// | GridMergeCellsMode.MergeColumnsInRow; 
this.gridGroupingControl1.TableModel.Options.MergeCellsLayout = GridMergeCellsLayout.Grid; 
this.gridGroupingControl1.TableModel.MergeCells.EvaluateMergeCells(this.gridGroupingControl1.TableControl.GridCellsRange); 
 
//Merging in ChildTable 
this.gridGroupingControl1.GetTableDescriptor("InvoiceSubDetails").Appearance.AnyRecordFieldCell.MergeCell = GridMergeCellDirection.Both; 
this.gridGroupingControl1.GetTableModel("InvoiceSubDetails").Options.MergeCellsMode = GridMergeCellsMode.OnDemandCalculation | GridMergeCellsMode.MergeRowsInColumn;// | GridMergeCellsMode.MergeColumnsInRow; 
this.gridGroupingControl1.GetTableModel("InvoiceSubDetails").Options.MergeCellsLayout = GridMergeCellsLayout.Grid; 
this.gridGroupingControl1.GetTableModel("InvoiceSubDetails").MergeCells.EvaluateMergeCells(this.gridGroupingControl1.GetTableControl("InvoiceSubDetails").GridCellsRange); 

UG link: 
 I need a way to export data into Excel. I can easily do that by exporting DataTable but it will not be formatted as I want it as looks like in GGC. 
You can export the grid data into excel by using GridGroupingExcelConverter.ExportToExcel  method (or) GroupingGridExcelConverterControl.GroupingGridToExcel method. 

Code snippet: 
GridGroupingExcelConverterControl excelConverter = new GridGroupingExcelConverterControl(); 
ExcelExportingOptions exportingOptions = new ExcelExportingOptions(); 
//Export the contents of the grid to Excel. 
excelConverter.ExportToExcel(this.gridGroupingControl1, "Sample.xlsx", exportingOptions); 
 
Process.Start("Sample.xlsx"); 
 
UG link: 
 
Note: 
To avail this export support, please add the below assemblies in your project, 
  1. Syncfusion.GridConverter.Windows.dll
  2. Syncfusion.XlsIo.Base.dll

Sample link: 

Regards, 
Piruthiviraj 


Dhairya Joshi
Replied On August 26, 2017 06:05 AM UTC

Hi Piruthiviraj,

Thank you so much for your help. Yess it did worked.

How ever I've one confusion Is there any option I can create columns at design time for nested or child tables (Design Times)?

Basically I want to create columns for both the views on design time so that I will be only binding data from DB.

For Main View we have options of Columns through which we can create it.



Arulpriya Ramalingam [Syncfusion]
Replied On August 28, 2017 12:37 PM UTC

Hi Dhairya, 
 
Thanks for your update. 
 
Query 
Response 
However I've one confusion Is there any option I can create columns at design time for nested or child tables (Design Times)? 
We regret to let you know that the GridGroupingControl does not have the support to add the columns for nested tables at design time. The columns for a nested table can be added programmatically by using the Columns property of respective GridTableDescriptor. You can get the correspondind table descriptor of the table by using GetTableDescriptor(). Please make use of below code and sample, 
 
//To add the columns for child table 
this.gridGroupingControl1.GetTableDescriptor("MyChildTable").Columns.Add("Category", "Category"); 
 
 
Note: 
You can bind the data source through designer directly in GridGroupingControl, 
Please refer to the below UG link, 
 
 
 
Regards, 
Arulpriya 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;