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

Custom Summary - summing for data that''s not in DataTable

This might sound like a strange request....but here goes.... I''m using Custom Summary objects which are all working very well, but now the users want a major change. ;-{ They want to include a total even if the data is not included in the DataSource. For example, if I was summing up a certain column for 5 records, the users want to apply a filter so that only 3 records are shown but still get the sum of the 5 records ;-{ I''ve noticed that ITreeTableSummary CreateSummaryMethod gets called once for each record in the data set regardless of the number of levels of grouping (which makes perfect sense) I was thinking of just adding all 5 records and then somehow hidding the 2 rows in the grid that they don''t want to see, eg: int dvIndex = dataview.Find(asset.AssetId); if (dvIndex != -1) { grid.GridTableModel.HideRows[dvIndex] = true; } Does this make any sense? Should I look at filtering? As you can imagine, any help would be very very welcome Jason

3 Replies

AD Administrator Syncfusion Team August 31, 2004 02:46 PM UTC

Jason, When you apply a filter then the summaries will only be calculated for the records that are displayed. This is the default behavior but I think you can change it. The following method in Recod determines the summaries that are returned for any record in the table and is called both for records that meet and do not meet filter criteria. /// public override ITreeTableSummary[] GetSummaries(Table parentTable, out bool summaryChanged) { summaryChanged = false; if (!MeetsFilterCriteria()) return parentTable.GetEmptySummaries(); else { SummaryDescriptorCollection sdc = parentTable.TableDescriptor.Summaries; return sdc.CreateSummaries(this); } } So, what you could do is derived a class from GridRecord and override this method and replace it with a simple call to return parentTable.TableDescriptor.SummariesCreateSummaries(this); Check out the GridPerf example. It shows how to derive from GridEngine, override its CreateXXX method(s) so that you can hook up your derived GridRecord class with the engine. Stefan

AD Administrator Syncfusion Team September 2, 2004 09:29 AM UTC

Stefan, Thank you very much for your help - it never fails to surprise me how extensible your grid is and the thought that''s gone into it. I did what you suggested and it''s all working great. The only problem I had was creating a filter on a boolean data column. This constructor wouldn''t filter: gridGroupingControl1.TableDescriptor.RecordFilters.Add( new RecordFilterDescriptor("[" + SELECTED + "] = true")); But this one did: RecordFilterDescriptor filter = new RecordFilterDescriptor(SELECTED, new FilterCondition( FilterCompareOperator.Equals, true)); gridGroupingControl1.TableDescriptor.RecordFilters.Add(filter); Thanks again Jason

AD Administrator Syncfusion Team September 2, 2004 02:06 PM UTC

Jason, you would have to change for "= 1" instead of "= true" in the expression string. We''ll add support for true / false keywords later. Regarding the summaries. I just ran into a similar scenario when working on FilterBar support where some summaries needed to be calculated on all available record. I now added a "IgnoreRecordFilterCriteria" property. So now you can have a mix of summaries that are calculated only for filtered records and summaries that are calculated on all records. Stefan

Live Chat Icon For mobile
Up arrow icon