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

Display name in grouping drop area

I am binding a datatable to a GroupingGrid control.If I drag the column to the drop area it dispalys whatever display(Header text) name given to the grid.But when I try to externally set the group by columns I am using Mapping name to add the group by columns. So when I do the grouping it displays mapping name..which is a database field name.I want to give meaning full name instead of database name. Is there anyway i can specify hearder text for grouping columns. i am using SortColumnDescriptorCollection groupedColumns = sfgAssetView.TableDescriptor.GroupedColumns; groupedColumns.Clear(); groupedColumns.Add(MappingName); Thx, Prathima

5 Replies

AD Administrator Syncfusion Team June 13, 2005 02:23 PM UTC

Did you try assigning this.gridGroupingControl1.TableDescriptor.Columns[MappingName]HeaderText (even if the column is not visible)? The grouping should pick up the HeaterText just as if you had used the UI to group it.

PV Prathima Venkobachar June 14, 2005 06:36 AM UTC

I have used GridColumDesc to specify mapping name and the headertext. GridColumnDescriptor colDescriptor1 = new GridColumnDescriptor(); I am adding GridColumnDescriptor to the visible columns. gridgroupingcontrol.TableDescriptor.Columns[MappingName] = colDescriptor1; gridgroupingcontrol.TableDescriptor.VisibleColumns.Add(colDescriptor1.Name); I will be getting the display column information and grouped column information in the datatable. I will add only display column to the visible column collection. I doesn''t add grouped coulmns to the visible columns.

AD Administrator Syncfusion Team June 14, 2005 08:14 AM UTC

I do not understand what you want to do. I thought you have this column in your grid: gridgroupingcontrol.TableDescriptor.Columns[MappingName] = colDescriptor1; gridgroupingcontrol.TableDescriptor.VisibleColumns.Add(colDescriptor1.Name); and when you group by this column you want to see something other than the MappingName, correct? Did you set gridgroupingcontrol.TableDescriptor.Columns[MappingName].HeaderText to what you want to see, and it does not work? Is that the problem? Or, do you want to do something entirely different, like have a column of key values in your grid, but display a column of description values instead? If so, you can use a foreign reference lookup. There is a sample in this thread. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=28679

PV Prathima Venkobachar June 14, 2005 10:46 AM UTC

My grouping column may not be a display filed in the grid. Also I have given proper headertext in the grid and displaying properly. I will try to explain what i am doing and what I want.Hope this will help you to understand and the problem. Based on the some criteria I will get the display columns and grouping column to be applied to the grid. I will create a datable to hold the values of display columns and grouped columns. This datatable I will bind it to the grid. As I am storing grouped column information only for the purpose of grouping ,I don''t add it to the visible column collection. As I told earlier grouping column may not be visible column in the grid. grouping column will be there in the grid but not added to the visible column collection. Here the problem is Grouping works fine.But the Groupdrop area displays the column name which is there in the datatable. I want to display a meaningfull name in the groupdroparea. Hope this helps. Prathima

AD Administrator Syncfusion Team June 14, 2005 11:35 AM UTC

You can try using QueryCellStyleInfo and setting the text there if it is your Caption cell being requested. Here is code that will swap the text when the grid is grouped on "Col2".
private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
	if(e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell)
		Group g = e.TableCellIdentity.DisplayElement.ParentGroup;
		if(g != null && g.CategoryColumns.Count > 0 && g.CategoryColumns[0].Name == "Col2")
			e.Style.Text = "SomethingMeaningfulFor-" + g.Category.ToString(); 

Live Chat Icon For mobile
Up arrow icon