Home Forums WPF controls Xceed DataGrid for WPF Sorting on Multiple Properties

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

    I am trying to sort on multiple properties and it doesn’t seem to work. It would appear that it only sorts on the last item in the SortDescriptions collection.

    Here is the XAML:

    <xcdg:DataGridCollectionViewSource x:Key=”CaseDatesCollectionView” Source=”{Binding Path=Case.DatesCollectionObservable}” Filter=”CaseDatesCollectionView_Filter”>
    <xcdg:DataGridCollectionViewSource.ItemProperties>
    <xcdg:DataGridItemProperty Name=”DateName” ValuePath=”TypeOfDate.name” DataType=”{x:Type s:String}” IsReadOnly=”True”/>
    <xcdg:DataGridItemProperty Name=”DateValue” ValuePath=”date” DataType=”{x:Type s:DateTime}” IsReadOnly=”False”/>
    <xcdg:DataGridItemProperty Name=”DateActual” ValuePath=”isactual” DataType=”{x:Type s:Boolean}” IsReadOnly=”False”/>
    <xcdg:DataGridItemProperty Name=”DateMemo” ValuePath=”memo” DataType=”{x:Type s:String}” IsReadOnly=”False”/>
    <xcdg:DataGridItemProperty Name=”DateType” ValuePath=”TypeOfDate.code” DataType=”{x:Type s:String}” IsReadOnly=”True”/>
    <xcdg:DataGridItemProperty Name=”DateSeq” ValuePath=”TypeOfDate.seq_no” DataType=”{x:Type s:Decimal}” IsReadOnly=”True”/>
    </xcdg:DataGridCollectionViewSource.ItemProperties>

    <xcdg:DataGridCollectionViewSource.SortDescriptions>
    <cm:SortDescription PropertyName=”DateType” Direction=”Descending”/>
    <cm:SortDescription PropertyName=”DateSeq” Direction=”Ascending”/>
    </xcdg:DataGridCollectionViewSource.SortDescriptions>

    </xcdg:DataGridCollectionViewSource>

    Imported from legacy forums. Posted by Wally (had 2388 views)

    Xceed Support
    Member
    Post count: 5658

    Hi,

    Would it be possible to provide a sample data set that reproduces your issue as well as a description of the “obtained” order of items and a description of the “expected” order?

    I know this sounds a little ‘harsh’ but it would help me reduce the investigation time a lot.

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

    User (Old forums)
    Member
    Post count: 23064

    Marcus,

    I can provide whatever you need.

    The data is a collection of two types of dates. System and Custom dates. The dates are stored in the CaseDate class, which is associated with the TypeOfDate class based on the key field in each class. Because we want the ability to sort on the CaseDate.date field and the CaseDate.TypeOfDate.name field we created the DataGridCollectionViewSource as I described in the first post. However, when those two fields are not being sorted on we want the order to be in CaseDate.TypeOfDate.code descending and CaseDate.TypeOfDate.seq_no ascending. The problem is it seems to only sort on the CaseDate.TypeOfDate.seq_no field.

    Also, because LINQ does not implement the INotifyCollectionChanged interface I wrap the CaseDates EnitySet in a class called ObservableEntitySet<T>. I don’t know if this could be causing the problem or not, but I have included the code below.

    Thanks for taking a look at this.

    Let me know if there is questions or suggestions,

    Wally

    ————————————————————————————————

    The classes and sample data are described below:

    The 1st data set is the default order that we want (code desc, seq_no asc), the 2nd data set is the actual order (seq_no asc):

    CaseDate class:
    date Datetime
    key char(10) //Yes I know, why isn’t it an Int. This is legacy data.

    TypeOfDate class:
    key char(10) //Yes I know, why isn’t it an Int. This is legacy data.
    code char(1) // S = System, C = Custom
    name char(25)
    seq_no Decimal(2,0) //Yes I know, why isn’t it an Int. This is legacy data.

    Sample Data:

    Name, Date, Code, Seq_no

    1st Data Set:

    Opened, 1/1/2008, S, 01
    IDE, 12/1/2007, S, 02
    Closed, null, S, 03
    Petitioned, null, S, 10
    Appointed, 1/1/2008, S, 15
    Claims Bar, null, S, 20
    Orig. ETFR, 11/19/2007, S, 25
    ETFR, null, S, 30
    TFR, null, S, 35
    TDR, null, S, 40
    NDR, 12/15/2007, S, 45
    Discharged, 12/21/2007, S, 50
    Tax Return Received, null, S, 65
    Tax Return Disposed, null, S, 70
    1ST CON’T DATE, 12/1/2008, C, 18
    2ND CON’T DATE, 12/7/2008, C, 19
    3RD CON’T DATE, 12/14/2008, C, 20
    4TH CON’T DATE, null, C, 21
    INITIAL REPORT, 11/1/2007, C, 22
    ATTORNEY’S 1ST FEE APP, null, C, 23
    ATTORNEY’S 2ND FEE APP, null, C, 24
    ATTORNEY’S 3RD FEE APP, null, C, 25
    ATTORNEY’S 4TH FEE APP, null, C, 26
    ACCTNT’S 1ST FEE APP, null, C, 27
    ACCTNT’S 2ND FEE APP, null, C, 28
    ACCTNT’S 3RD FEE APP, null, C, 29
    ACCTNT’S 4TH FEE APP, null, C, 30

    2nd Data Set:
    Opened, 1/1/2008, S, 01
    IDE, 12/1/2007, S, 02
    Closed, null, S, 03
    Petitioned, null, S, 10
    Appointed, 1/1/2008, S, 15
    1ST CON’T DATE, 12/1/2008, C, 18
    2ND CON’T DATE, 12/7/2008, C, 19
    Claims Bar, null, S, 20
    3RD CON’T DATE, 12/14/2008, C, 20
    4TH CON’T DATE, null, C, 21
    INITIAL REPORT, 11/1/2007, C, 22
    ATTORNEY’S 1ST FEE APP, null, C, 23
    ATTORNEY’S 2ND FEE APP, null, C, 24
    Orig. ETFR, 11/19/2007, S, 25
    ATTORNEY’S 3RD FEE APP, null, C, 25
    ATTORNEY’S 4TH FEE APP, null, C, 26
    ACCTNT’S 1ST FEE APP, null, C, 27
    ACCTNT’S 2ND FEE APP, null, C, 28
    ACCTNT’S 3RD FEE APP, null, C, 29
    ETFR, null, S, 30
    ACCTNT’S 4TH FEE APP, null, C, 30
    TFR, null, S, 35
    TDR, null, S, 40
    NDR, 12/15/2007, S, 45
    Discharged, 12/21/2007, S, 50
    Tax Return Received, null, S, 65
    Tax Return Disposed, null, S, 70

    public class ObservableEntitySet<T> : IList<T>, INotifyCollectionChanged where T : class
    {
    EntitySet<T> _extraSet;
    EntitySet<T> _entitySet;

    public ObservableEntitySet(EntitySet<T> entitySet)
    {
    _extraSet = new EntitySet<T>();
    _entitySet = entitySet;
    }

    #region IList Members

    public void Add(T item)
    {
    _entitySet.Add(item);
    OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, Count-1));
    }

    public void AddExtra(T item)
    {
    _extraSet.Add(item);
    OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, Count-1));
    }

    public void Clear()
    {
    _extraSet.Clear();
    _entitySet.Clear();
    OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
    }

    public bool Contains(T item)
    {
    return _extraSet.Contains(item) || _entitySet.Contains(item);
    }

    public void CopyTo(T[] array, int arrayIndex)
    {
    _extraSet.CopyTo(array, arrayIndex);
    _entitySet.CopyTo(array, arrayIndex + _extraSet.Count);
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
    return new ObservableEntitySetEnumerator<T>(this);
    }

    IEnumerator<T> IEnumerable<T>.GetEnumerator()
    {
    return new ObservableEntitySetEnumerator<T>(this);
    }

    public int IndexOf(T item)
    {
    if (_extraSet.Contains(item))
    return _extraSet.IndexOf(item);
    if (_entitySet.Contains(item))
    return _entitySet.IndexOf(item) + _extraSet.Count;
    return -1;
    }

    public void Insert(int index, T item)
    {
    if (index == -1)
    index = 0;
    if (index < _extraSet.Count)
    _extraSet.Insert(index, item);
    else
    _entitySet.Insert(index – _extraSet.Count, item);
    OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, index));
    }

    public bool Remov

    Imported from legacy forums. Posted by Wally (had 3809 views)

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