Home Forums WPF controls Xceed DataGrid for WPF How to remove a sort option?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #25108 |


    My data comes into the form sorted by my data’s Id. If I click the ColumnManagerCell, it will sort by ascending alphabetical, then by descending alphabetical, and then cycle back through all three. However, I want to eliminate the sort by Id.

    I have my data correctly sorting in ascending alphabetical on load with the following code:

    Binding bind = new Binding();
    ListCollectionView lcv = new ListCollectionView(ObservableCollection<T>);
    lcv.SortDescriptions.Add(new SortDescription(“City”, ListSortDirection.Ascending));
    bind.Source = lcv;
    this.MyGrid.SetBinding(DataGridControl.ItemsSourceProperty, bind);

    Then, when I click the ColumnManagerCell, I switch to descending, which I want. However, my next click returns to the sort by Id. How can I eliminate the sort by Id completely, or how can I programmatically (in c# or xaml) trigger a sort based on clicking on the ColumnManagerCell?

    Merci en avance,


    Imported from legacy forums. Posted by Neil (had 598 views)

    User (Old forums)
    Post count: 23064

    The default behavior is to change to SortDirection.Ascending -> SortDirection.Descending –> SortDirection.None. When you see it sorts by id, it is actually SortDirection.None. I don’t think there is a way to overwrite that behavior in 1.2. Maybe the behavior should be configurable via an additional property. I think it’s a nice feature to have in the next version of DataGrid.

    Imported from legacy forums. Posted by nat (had 312 views)

    Xceed Support
    Post count: 5658

    Based on the description you gave, it looks like the list has a natural order that is based on the ID.

    When all sorts are removed (SortDirection.None ), we are returning to the natural order of the rows.

    Considering this, it doesn’t seem like there is a bug or that there is something we can do about the ordering of your rows (unless you manually re-order the rows in the source collection ).

    En espérant avoir aidé.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 3199 views)

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