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
close icon

Customizing CaptionText in GroupingGrid

I''d like to use the {Category} descriptor for filling in the CaptionText in the GroupingGrid. However, my datasource is not a DataTable. I have a custom datasource where I''ve adapted IBindingList to handle dynamic updates. Some of the column values need to be translated via a lookup table. The display vales for cells are handled via: QueryCellStyleInfo like so: if( e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell ) { if( e.TableCellIdentity.Column != null && HaveTranslation( e.TableCellIdentity.Column.MappingName )) { GridRecord record = (GridRecord) e.TableCellIdentity.DisplayElement.ParentRecord; object fieldValue = record.GetValue( e.TableCellIdentity.Column.MappingName ); e.Style.CellValue = TranslateFromValue( null, e.TableCellIdentity.Column.MappingName, fieldValue ); e.Style.TextAlign = GridTextAlign.Left; } } When I group by one of these translated columns, the group header shows {Category} as the un-translated value. Is there a way to also provide a lookup when this is drawn ?

3 Replies

AD Administrator Syncfusion Team October 1, 2004 05:45 PM UTC

Hi Adam, In QueryCellInfo you can check for e.TableCellIdentity.TableCellType == GridTableCellType.GridTableCellType.GroupCaptionCell and set the text that should be shown for the caption bar. Stefan


AM Adam Miller October 1, 2004 07:14 PM UTC

Stefan, that''s not working. What I''m doing is: mGroupingGrid.TableDescriptor.ChildGroupOptions.CaptionText = "{CategoryName}: {Category}"; When I group by a column whose value is translated, CaptionText shows the untranslated value. My DataSource has a Column --> Client. In the source Client has numerical values. I want to display the Client''s name. This is retreived from a lookup table, via the code I posted above int the QueryCellStyleInfo handler. So, my group captions are showing: Client: 1 Client: 2 Instead of: Client: Foo Client: Bar If there''s a way to provide this field in the SummaryRow itself where it''s normal column position is, that would be great also. My SummaryRow looks like this: GridSummaryRowDescriptor totals = new GridSummaryRowDescriptor("Totals", new GridSummaryColumnDescriptor[] { new GridSummaryColumnDescriptor("OrderedShares", SummaryType.Int32Aggregate, "OrderedShares", "{Sum}"), new GridSummaryColumnDescriptor("ExecutedShares", SummaryType.Int32Aggregate, "ExecutedShares", "{Sum}"), new GridSummaryColumnDescriptor("NumOrders", SummaryType.Int32Aggregate, "NumOrders", "{Sum}"), new GridSummaryColumnDescriptor("NumFills", SummaryType.Int32Aggregate, "NumFills", "{Sum}"), new GridSummaryColumnDescriptor("TotalValue", SummaryType.DoubleAggregate, "TotalValue", "{Sum}") } ); Then added to the grid as so: totals.Visible = true; mGroupingGrid.TableDescriptor.SummaryRows.Add( totals ); mGroupingGrid.TableDescriptor.ChildGroupOptions.ShowCaptionSummaryCells = true; mGroupingGrid.TableDescriptor.ChildGroupOptions.CaptionText = "{CategoryName}: {Category}"; mGroupingGrid.TableDescriptor.ChildGroupOptions.CaptionSummaryRow = "Totals";


AD Administrator Syncfusion Team October 3, 2004 11:39 PM UTC

Hi Adam, sorry for the late reply. Attached find a sample that adds a unbound field to do the mapping. You can group by this unbound field and at the same time hide it in your columns collecion. The sample also handles QueryCoveredRange and disables the covering for the TopLevelGroup caption and has some comments what you should do in QueryCellStyleInfo. Stefan UnboundField_1932.zip

Loader.
Live Chat Icon For mobile
Up arrow icon