Home Forums WinForms controls Xceed Grid for WinForms Group Sort/ Order

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #15977 |

    Hi,

    What’s the proper way to set the order groups should be displayed? I tried using the level property, since it looks like an index, but it’s read only. Tried to reorder the Groups array, but it can’t be done either.

    Cheers,

    Imported from legacy forums. Posted by Testing (had 3626 views)

    User (Old forums)
    Member
    Post count: 23064

    To elaborate on what I’m trying to do is to have always a specific group on top and another at the bottom, with all the other groups generated by the system in the middle. Like a header group and footer group. Under certain circumstances , rows that belongs to groups that are in the middle will be moved to either the bottom or top one.

    Imported from legacy forums. Posted by Testing (had 427 views)

    Xceed Support
    Member
    Post count: 5658

    You could use the <a href=”http://doc.xceedsoft.com/products/Xceedgrid/Custom_Sorting.html”&gt; custom sorting</a> to pre-decide which group is going to be on top by explicitly calling a sort on the specific column and preventing the user from re-sorting after.

    The following code will always show the group with the “2” value on top and the “3” value at the bottom:

    <code>
    for( int j = 0; j < 4; j++ )
    {
    Column col = new Column( “Column”+j.ToString(), typeof(int) );
    gridControl1.Columns.Add( col );
    }

    gridControl1.Columns[ 0 ].DataComparer = new SpecialComparer();

    for( int i = 0; i < 20; i++ )
    {
    Xceed.Grid.DataRow row = gridControl1.DataRows.AddNew();
    foreach( Cell cell in row.Cells )
    {
    cell.Value = i % 5;
    }
    row.EndEdit();
    }

    Group group = new Group( “Column0” );
    gridControl1.GroupTemplates.Add( group );
    gridControl1.Columns[ 0 ].SortDirection = SortDirection.Ascending;

    gridControl1.UpdateGrouping();
    ( ( ColumnManagerRow )gridControl1.FixedHeaderRows[ 1 ] ).AllowSort = false;
    ( ( GroupByRow )gridControl1.FixedHeaderRows[ 0 ] ).AllowGroupingModification = false;
    </code>

    Imported from legacy forums. Posted by CharlesB (had 513 views)

    User (Old forums)
    Member
    Post count: 23064

    Thank you very much for the information. It was very helpful and it’s doing what I wanted it to do now, however, I have another question.

    It seems like everytime the UpdateGrouping() is called, the grid resets the entire grid, scrolling back to the top of it and selecting the first row, deselecting anything that might be selected. Is there a setting to prevent that behavior.

    Imported from legacy forums. Posted by Testing (had 441 views)

    Xceed Support
    Member
    Post count: 5658

    No, this is a built-in behavior (by design). To work-around this behavior, you can keep a list of the Selected DataRows before the UpdateGrouping is called and subscribe to the Application.Idle event. In the event, (first, you unsubscribe from it) you re-add the selection.

    Imported from legacy forums. Posted by CharlesB (had 4771 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.