简体   繁体   中英

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

Just thought I'd also note that if you want to clear the group by here is how: myGrid.Rows.Band.SortedColumns.Clear()

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; grid1.DisplayLayout.ViewType = ViewType.OutlookGroupBy; grid1.Rows.Band.Columns[0].IsGroupByColumn = true; grid1.Rows.Band.Expandable = Expandable.Yes;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM