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

Totaling cell values in a row

I using a GDBG master-detail grid. There are 3 columns in the detail row that I''d like to add up and display in a read-only SUBTOTAL column for that row. In addition, I want to summarize all of the detail row SUBTOTAL columns and display that value in a read-only TOTAL column in the related master grid row. I''m still trying to understand what events fire when and could really use some help. I bet this has been asked a million times. Thank you. I love your product!

1 Reply

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\\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.

Live Chat Icon For mobile
Up arrow icon