Hello Team,
Hope everyone is safe,
I need help merging data from two tables into single data grid.
I've two lists as follow :
1) Invoice Details
InvoiceId | Customer Name | SubTotal | Discount | Total amount |
1 | A | 100 | 0 | 100 |
2 | B | 200 | 0 | 200 |
2) Invoice Master Details
InvoiceId | ItemName | Qty | Amount |
1 | TestA | 1 | 25 |
1 | TestB | 1 | 25 |
1 | TestC | 2 | 50 |
2 | TestA | 1 | 25 |
2 | TestB | 1 | 25 |
2 | TestC | 2 | 50 |
Now I am joining this two tables and getting following results using inner join and I am attaching this query result as item source for sfDataGrid so i will be getting following output.
InvoiceId | Customer Name | ItemName | Qty | Amount | SubTotal | Discount | Total amount |
1 | A | TestA | 1 | 25 | 100 | 0 | 100 |
1 | A | TestB | 1 | 25 | 100 | 0 | 100 |
1 | A | TestC | 2 | 50 | 100 | 0 | 100 |
2 | B | TestA | 2 | 25 | 200 | 0 | 200 |
2 | B | TestB | 2 | 25 | 200 | 0 | 200 |
2 | B | TestC | 2 | 50 | 200 | 0 | 200 |
What I want to achieve is as follow :
Invoice Id | CustomerName | ItemName | Qty | Amount | SubTotal | Discount | Total Amount |
1 | A | TestA | 1 | 25 | 100 | 0 | 100 |
TestB | 1 | 25 | |||||
TestC | 2 | 50 | |||||
2 | B | TestA | 2 | 25 | 200 | 0 | 200 |
TestB | 2 | 25 | |||||
TestC | 2 | 50 |
I want to configure sfDatagrid such a way that it show data in above format and it must merge redundant values based on master invoice id.
I went by documentation of Merge cells (https://help.syncfusion.com/wpf/datagrid/merge-cells#merging-cells-based-on-the-content ) but I've doubt on few things.
1) How to achieve above results based on the data i've provided above.
2) If InvoiceId 1 and 2 both are having same SubTotal and Total Amount then i dont want them to merge into single cells across invoice id 1 and 2 because both are different, how can i prevent it from happening. I want data grid to merge cells by following group by invoice id.
3) I've enabled FilterRow for this data grid will grouping work with filter row ?
4) I've enabled ExportToExcel as well for same control, if cells are merged will it reflect same way in excel as well ?
Please response on above as soon as possible.
Thank you
Dhairya joshi.
Queries |
Solutions | |
How to achieve above results based on the data i've provided above. |
You can merge the redundant data in adjacent cells in a row or columns using QueryCoveredRange event. For more information related to Merging cells based on the content, please refer the user guide documentation,
| |
If InvoiceId 1 and 2 both are having same SubTotal and Total Amount then i dont want them to merge into single cells across invoice id 1 and 2 because both are different, how can i prevent it from happening. I want data grid to merge cells by following group by invoice id. |
Your requirement can be achieved by customize the GetRange method and QueryCoveredRange event in SfDataGrid. Please refer the below code snippet,
| |
I've enabled FilterRow for this data grid will grouping work with filter row ?
|
Yes. Grouping work with filter row enabled in SfDataGrid. | |
I've enabled ExportToExcel as well for same control, if cells are merged will it reflect same way in excel as well ? |
You can export the merged cells to excel by setting the ExcelExportingOptions.ExportMergedCells property. For more information related to Export merged cells to Excel, please refer the user guide documentation,
|