How can 'Group By' on a ultrawingrid column?
开发者_开发技巧On the control appears a feature saying 'Drag a column header to gorup by that column'. Can i do that programmatically. Are there any properties or do I need to embed SQL statements?
Thanks, Sun
You need to add the column to the SortedColumns collection in the band:
private void SwitchGroupByFor(string key) //key stands for the ultragridcolumn key
{
var band = grid.DisplayLayout.Bands[0];
var sortedColumns = band.SortedColumns;
sortedColumns.Add(key, false, true); //last flag indicates is a group by column
}
hth
Take a look here : http://forums.infragistics.com/forums/p/2418/15231.aspx#15231 and here : http://forums.infragistics.com/forums/t/5928.aspx
These lines are the one that do the magic :
grid1.DisplayLayout.ViewType = ViewType.OutlookGroupBy;
grid1.Rows.Band.Columns[0].IsGroupByColumn = true;
grid1.Rows.Band.Expandable = Expandable.Yes;
Just thought I'd also note that if you want to clear the group by here is how: myGrid.Rows.Band.SortedColumns.Clear()
精彩评论