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

How to group rows by default on initial load

Hello,

Is there a way to set by default that whenever the Grid Group control loads rows of data from the dB, it'd automatically group them by a specific column?

For example an example here
http://websamples.syncfusion.com/docs/gridwin/ug/default.html
illustrates that user can drag and drop the column name into the GroupDropArea in order to group the rows by that column. But I want this to be done on initial page load without requiring the user to do this.

Thanks.

3 Replies

HA haneefm Syncfusion Team October 2, 2007 05:41 PM UTC

Hi Titus,

At Loadtime, you can programatically group the grid by adding the column to the TableDescriptor.GroupedColumns collection.

grid.TableDescriptor.GroupedColumns.Add("Col1"); //group by the column whose name is "Col1".

Best regards,
Haneef


TC Titus Cheung October 4, 2007 02:10 PM UTC

Hi,

Thanks for the info.
Now that it's grouping on initial load, how do I set it such that it'd display a unique group name? For example, I'm sorting by a contactType column. This column has values "consultant", "engineer", "accountant", etc.

I found the section of code that does this and currently it has:
this.gridGroupingControl1.ChildGroupOptions.CaptionText = "{CategoryCaption}: {Category} - {RecordCount} Items";

and I need to change it to something like...
this.gridGroupingControl1.ChildGroupOptions.CaptionText = "{cellData}: {Category} - {RecordCount} Items";

Thanks


HA haneefm Syncfusion Team October 4, 2007 08:24 PM UTC

Hi Titus,

How can i change text of grid caption?
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The Group CaptionText can be customized using the TableDescriptor.ChildGroupOptions.CaptionText property (gridGroupingGrid.TableDescriptor.ChildGroupOptions.CaptionText = "{CategoryName}: {Category}";).

If you want to append the celldata in a gridcaptioncell, then handle QueryCellStyleInfo event to have your own text, there check for the e.TableCellIdentity.TableCellType to be GroupCaptionCell and set the text. Kindly refer to the forum thread below for more details.

http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=11530
http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=34184

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon