Welcome to the Xceed Community | Help
Community Search  
More Search Options

DataGridVirtualizingCollectionViewSource sorting Problem

Sort Posts: Previous Next
  •  07-21-2009, 8:43 AM Post no. 22742

    DataGridVirtualizingCollectionViewSource sorting Problem


    my english is not so good but i try my best. Smile

     I use the DataGridVirtualizingCollectionViewSource for lazy loading and show the Result in an TableView. When i click on the Header for sorting the Data, than nothing changes. The basic Problem i think is, the Application don't know that it must collect sorted data for the View.It takes everytime the same Data. After the Click my Method xx_QueryItems()  runs. But i can't find an propertie that says me -> "give me Data for an sorted View".

    How can i sort this type of DataGrid ?

    If posible plz give me an example. thx.


  •  07-21-2009, 10:24 AM Post no. 22753 in reply to 22742

    Re: DataGridVirtualizingCollectionViewSource sorting Problem


    For sorting on a custom or user defined objects, you should implement your own Sorting mechanism as already described in the online documentation at the page: http://doc.xceedsoft.com/products/XceedWpfDataGrid/Sorting_Data.html.

    The example 5 should help you address your issue.




    Xceed - Software Developer and Technical Support
  •  07-22-2009, 2:59 AM Post no. 22789 in reply to 22753

    Re: DataGridVirtualizingCollectionViewSource sorting Problem

    Thx for your Answer but it didn't work.

    I wrote my own Comparer-Class and set the "SortComparer" Property like Xceed did it in Example 5. For debug i set an Breakpoint at my Comparer-Class but at Runtime it was never used.


     DataGridItemProperty oItemProperty = new DataGridItemProperty();
                        oItemProperty.Name = oViewField.FieldName;
                        oItemProperty.Title = oViewField.Caption;
                        oItemProperty.DataType = cvf.LastFieldProperty.DataType;
                        oItemProperty.CalculateDistinctValues = oViewField.DistinctValues;
                        oItemProperty.SortComparer = new StringComparer();

      this.ViewSource = new DataGridVirtualizingCollectionViewSource();
                this.ViewSource.QueryItems += new EventHandler<QueryItemsEventArgs>(DataGridVirtualizingCollectionViewSource_QueryItems);
                this.ViewSource.QueryItemCount += new EventHandler<QueryItemCountEventArgs>(DataGridVirtualizingCollectionViewSource_QueryItemCount);
                this.ViewSource.AutoCreateItemProperties = false;
                this.ViewSource.AutoFilterMode = AutoFilterMode.And;
    // Bind the DataGrid to the DataGridControl
                Binding b = new Binding() { Source = this.ViewSource };
                this.dgc.SetBinding(DataGridControl.ItemsSourceProperty, b);


    Do i something wrong?

  •  07-22-2009, 9:38 AM Post no. 22801 in reply to 22789

    Re: DataGridVirtualizingCollectionViewSource sorting Problem

    The StringComparer class is an abstract class and therefore cannot be instantiated. You will need to use one of its derived classes or provide your own IComparer implementation, as demonstrated in the example Mohamed referenced.

    If you use the AddressComparer class demonstrated in the example and provide it to a DataGridItemProperty that contains strings, are you able to sort the columns? 

    Do you have any errors in the output window? 

    Senior Technical Writer
    - Xceed Software

    In three words I can sum up everything I've learned about life: it goes on.
  •  07-22-2009, 9:51 AM Post no. 22803 in reply to 22801

    Re: DataGridVirtualizingCollectionViewSource sorting Problem

    I'm sorry but you misunderstand my Post. I took the Quellcode of the AddressComparer and changed it to StringComparer. It has nearly the same code. No change no error at Runtime.


  •  07-22-2009, 10:24 AM Post no. 22807 in reply to 22803

    Re: DataGridVirtualizingCollectionViewSource sorting Problem

    My apologies. When using the DataGridVirtualizingCollectionViewSource, sorting is not done locally, it is done in the server; therefore, the custom sort comparer will never be used.

    I will update the documentation to reflect this information. 

    Senior Technical Writer
    - Xceed Software

    In three words I can sum up everything I've learned about life: it goes on.
  •  01-19-2010, 8:07 PM Post no. 25475 in reply to 22807

    Re: DataGridVirtualizingCollectionViewSource sorting Problem

    Does this mean there is no way to do custom sorting when using a virtualized datagrid?
  •  01-22-2010, 8:56 AM Post no. 25514 in reply to 25475

    Re: DataGridVirtualizingCollectionViewSource sorting Problem

    Hi John,

    Unfortunately, custom sorting in a virtualized DataGrid is not currently supported.


    Diane Lafontaine
    Developer Technical Support
    Xceed Software Inc.

    ** Quick Tip: Clients with an active support subscription should be sending their questions by email if they wish to benefit from the faster response time. Thanks!
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2011 Xceed Software Inc.