AD
Administrator
Syncfusion Team
June 16, 2005 08:08 AM UTC
If you use a GridGroupingControl for your grids, you can do this more easily using the technique shouwn in the \Syncfusion\Essential Studio\3.2.1.0\Windows\Grid.Windows\Samples\Grouping\SummaryInCaption sample.
To do it in a GridDataBoundGrid, this will take significant work. Getting the summary row in teh details, you could use a technique like the one described in this KB. http://www.syncfusion.com/Support/article.aspx?id=10398
To get the summaries in the parent row is more of a problem. You would have to add unbound columns (get add a GridBoundColumn with a MappingName not in your Master DataTable). You would then handle grid.Model.QueryCellInfo to provide the values to these unbound columns on demand. Here is where the a problem comes up. The details grid is not really there until you display it. So, you would not be able to just grab this summary information from the details grid (unless all teh details are always visible). So, one way around this would be to loop through all the parent rows. For each row, create a DataView that holds teh rows from that particular detail by setting the RowFilter property appropriately when you create the DataView. Then loop through the DataView and compute the summary information you want, and store it in a Hashtable with the key being the parentColumnValue of the master-details relation(or ArrayList if you are not allowing sorting on the master grid). Then you could handle the CurrentCellValidateChanges in the details grid to adjust the sum cached in the Hashtable if the currentcell being changed in the details is part of the summary information. After the Hashtable is completely computed, you can use it it grid.Model.QueryCellInfo to provide the values for you unbound column in the master grid.