Home Forums WPF controls Xceed DataGrid for WPF GroupDescription fails first time

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

    I am using the latest v1.1 plus update. I create the columns in code (assigning FieldNames) and assign a GroupDescription as follows:

    this.Items.GroupDescriptions.Clear();
    DataGridGroupDescription gd = new DataGridGroupDescription(“CommonName”);
    this.Items.GroupDescriptions.Add(gd);

    where CommonName is the Title, Fieldname, DataBinding of the column that I would like to group on.

    On display of the grid, the data is complete and the Grouping Header contains the command button that corresponds to this group. However the grouping has not taken place.

    If I click the Group button then the grouping happens as expected (cycling through the 3 clicks for ascending, descending and no sort also works).

    How do I get the grouping to work immediately rather than having to click the Group button?

    Imported from legacy forums. Posted by Derek (had 3699 views)

    User (Old forums)
    Member
    Post count: 23064

    This would be my fault as I had not implemented the DataGridCollectionView to wrap the ObservableCollection. I was still attaching the ObservableCollection to the grid’s ItemsSource directly.

    Imported from legacy forums. Posted by Derek (had 2723 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Derek, you might know the answer to the question I have been trying to find.

    Using the code posted initialy by you, is there any way you can indicate to the group to be sorted by the value of the items in other column within the grid?

    Thanks in advance. 

     

    Imported from legacy forums. Posted by Giuliano (had 365 views)

    User (Old forums)
    Member
    Post count: 23064

    Not something I have looked at, but can you do anything with the SortDescriptions collection of the DataGridCollectionView at the same time that you set the Grouping? For example,

    DataGridCollectionView dgcv = this.ItemsSource as DataGridCollectionView;

    dgcv.SortDescriptions.Clear();

    dgcv.SortDescriptions.Add(new SortDescription(“sort column”, ListSortDirection.Ascending));

     

    Imported from legacy forums. Posted by Derek (had 2080 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for your reply Derek.

    I tried your suggestions but as soon as I declared the group description, it orders the data by that group and the previous column sorted (by the code provided) is totally ignored.

    Any suggestions, maybe there is a way to change the sorting of a group by overriding the xceed built-in sorting?

     

     

    Imported from legacy forums. Posted by Giuliano (had 2489 views)

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