Home Forums WPF controls Xceed DataGrid for WPF Group doesn’t work for me. Each item becomes one group

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

    Hi,

    I am sure the Group functionality works for most of you guys, however, in my case, I couldn’t get it right.

    Here is what we do: we have a collection of Department for example, and each Department has properties such as Id, ShortName, and FullName. The complication is, each of these propertis is not of .NET primitive data type, like string, or int; instead, they are of our own ComponentModel types, e.g. IntegerProperty, TextProperty. and the IntegerProperty then contains a property called “Value” that stores the real value (primitive data types this time, finally) of the Department Id, for example. Apart from “Value”, we also have “DisplayValue”, “DisplayName”, etc. on each of our own ComponentModel property types.

    Now comes to XAML, I have tried all the following combinations, but none of them work. (By not working, I mean, when I drag a column header onto the GroupByControl area or specify <xcdg:DataGridCollectionViewSource.GroupDescriptions> in XAML, the result is always that each item becomes one group, event though multiple Group headings display that the same value, e.g.

    v Category: Development (1 item) ————————–
    …..
    v Category: Development (1 item) ————————–
    …..
    v Category: Finance (1 item) ————————–
    …..
    v Category: Finance (1 item) ————————–
    …..
    v Category: Finance (1 item) ————————–
    …..

    1.
    <xcdg:DataGridCollectionViewSource x:Key=”depts” Source=”{Binding Source={StaticResource DepartmentList}}”/>

    <xcdg:DataGridControl AutoCreateColumns=”True” ItemsSource=”{Binding Source={StaticResource depts}}”/>

    2.
    <xcdg:DataGridCollectionViewSource x:Key=”depts” Source=”{Binding Source={StaticResource DepartmentList}}”>
    <xcdg:DataGridCollectionViewSource.ItemProperties>
    <xcdg:DataGridItemProperty Name=”ShortName”/>
    <xcdg:DataGridItemProperty Name=”Category”/>
    </xcdg:DataGridCollectionViewSource.ItemProperties>
    </xcdg:DataGridCollectionViewSource>

    <xcdg:DataGridControl AutoCreateColumns=”True” ItemsSource=”{Binding Source={StaticResource depts}}”/>

    3.
    <xcdg:DataGridCollectionViewSource x:Key=”depts” Source=”{Binding Source={StaticResource DepartmentList}}”>
    <xcdg:DataGridCollectionViewSource.ItemProperties>
    <xcdg:DataGridItemProperty Name=”ShortName”/>
    <xcdg:DataGridItemProperty Name=”Category”/>
    </xcdg:DataGridCollectionViewSource.ItemProperties>

    <xcdg:DataGridCollectionViewSource.GroupDescriptions>
    <xcdg:DataGridGroupDescription PropertyName=”Category” >
    <xcdg:DataGridGroupDescription.SortComparer>
    <sagcm:MyComparer/>
    </xcdg:DataGridGroupDescription.SortComparer>
    </xcdg:DataGridGroupDescription>
    </xcdg:DataGridCollectionViewSource.GroupDescriptions>
    </xcdg:DataGridCollectionViewSource>

    <xcdg:DataGridControl AutoCreateColumns=”True” ItemsSource=”{Binding Source={StaticResource depts}}”/>

    4.
    <xcdg:DataGridCollectionViewSource x:Key=”depts” Source=”{Binding Source={StaticResource DepartmentList}}”>
    <xcdg:DataGridCollectionViewSource.ItemProperties>
    <xcdg:DataGridItemProperty Name=”ShortName”/>
    <xcdg:DataGridItemProperty Name=”Category”/>
    </xcdg:DataGridCollectionViewSource.ItemProperties>

    <xcdg:DataGridCollectionViewSource.GroupDescriptions>
    <xcdg:DataGridGroupDescription PropertyName=”Category” >
    <xcdg:DataGridGroupDescription.SortComparer>
    <sagcm:MyComparer/>
    </xcdg:DataGridGroupDescription.SortComparer>
    </xcdg:DataGridGroupDescription>
    </xcdg:DataGridCollectionViewSource.GroupDescriptions>
    </xcdg:DataGridCollectionViewSource>

    <xcdg:DataGridControl AutoCreateColumns=”True” ItemsSource=”{Binding Source={StaticResource depts}}”>
    <xcdg:DataGridControl.Columns>
    <xcdg:Column FieldName=”Rating” Title=”Rating” DisplayMemberBinding=”{Binding Category.DisplayValue}}” ReadOnly=”True”/>
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGrodControl>

    By the way, I can’t use ValuePath in DataGridItemProperty, as soon as I use it, it will crash when I do sorting or grouping.

    Any help would be greatly appreciated.

    Mark

    Imported from legacy forums. Posted by Mark (had 2222 views)

    Xceed Support
    Member
    Post count: 5658

    Value path would definitely be the way to go…

    If you could provide more information on the crash, then we could help you debug from that point.

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

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