Home Forums WPF controls Xceed DataGrid for WPF v1.2: StatCell not working

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

    I have UserControl defined in xaml

    <xcdg:DataGridCollectionViewSource x:Key=”viewsource” Filter=”source_Filter”
    Source=”{Binding Source={StaticResource dataset}, Path=Lines}”>
    <xcdg:SumFunction ResultPropertyName=”month2_sum” SourcePropertyName=”Month2″/>
    <xcdg:DataGridControl ItemsSource=”{Binding Source={StaticResource viewsource}}” AutoCreateColumns=”False” ReadOnly=”True”>
    <xcdg:GroupHeaderFooterItemTemplate VisibleWhenCollapsed=”True”>
    <xcdg:StatRow Background=”AliceBlue”>
    <xcdg:StatCell FieldName=”Month2″ ResultPropertyName=”month2_sum” Background=”Yellow”/>
    <xcdg:Column FieldName=”FinCode” Title=”FinCode” ReadOnly=”True” Width=”75″/>
    <xcdg:Column FieldName=”Description” Title=”Description” Width=”150″/>
    <xcdg:Column FieldName=”Month1″ Title=”Jan” Width=”50″/>
    <xcdg:Column FieldName=”Month2″ Title=”Feb” Width=”50″/>
    <xcdg:Column FieldName=”Month3″ Title=”Mar” Width=”50″/>
    <xcdg:Column FieldName=”Month4″ Title=”Apr” Width=”50″/>
    <xcdg:Column FieldName=”Month5″ Title=”May” Width=”50″/>
    <xcdg:Column FieldName=”Month6″ Title=”Jun” Width=”50″/>
    <xcdg:Column FieldName=”Month7″ Title=”Jul” Width=”50″/>
    <xcdg:Column FieldName=”Month8″ Title=”Aug” Width=”50″/>
    <xcdg:Column FieldName=”Month9″ Title=”Sep” Width=”50″/>
    <xcdg:Column FieldName=”Month10″ Title=”Oct” Width=”50″/>
    <xcdg:Column FieldName=”Month11″ Title=”Nov” Width=”50″/>
    <xcdg:Column FieldName=”Month12″ Title=”Dec” Width=”50″/>

    and in code behind

    public partial class CategoryView
    public CategoryView()
    DataGridCollectionViewSource source = (DataGridCollectionViewSource)Resources[“viewsource”];
    source.ItemProperties.Add(new DataGridItemProperty(TypeDescriptor.GetProperties(typeof(BudgetDS.LinesRow))[“CategoryCode”]));
    source.ItemProperties.Add(new DataGridItemProperty(TypeDescriptor.GetProperties(typeof(BudgetDS.LinesRow))[“FinCode”]));
    source.GroupDescriptions.Add(new DataGridGroupDescription(“CategoryCode”));
    Loaded += CategoryView_Loaded;

    void CategoryView_Loaded(object sender, RoutedEventArgs e)
    DataGridCollectionViewSource source = (DataGridCollectionViewSource)Resources[“viewsource”];

    void source_Filter(object sender, DataGridFilterEventArgs e)
    BudgetDS.LinesRow line = e.Item as BudgetDS.LinesRow;
    e.Accepted = (line != null) && (line.CategoryCode == CategoryCode);

    public static DependencyProperty CategoryCodeProperty = DependencyProperty.Register(“CategoryCode”, typeof(string), typeof(CategoryView), new PropertyMetadata(null));
    public string CategoryCode
    get { return GetValue(CategoryCodeProperty) as string; }
    set { SetValue(CategoryCodeProperty, value); }


    I can’t force StatCell to show anything in it. Grouping works, StatCell shows up in yellow as I defined, but it’s empty.

    This UserControl should show Lines only for one category and sum all months in footer. Resource ‘dataset’ is a Dataset defined in Application scope.
    ‘CategoryCode’ and ‘FinCode’ are not columns in dataset, but properties defined in dataset partial code that retrive string values from related tables.

    I even tried to inherit from StatCell and override Initialize method to find why it’s not working and the only reason I found is that GetValue(DataGridControl.StatContextProperty) is null

    In DataGridControl.OnItemsSourceChanged() method I found such code

    DataGridCollectionView view = newValue as DataGridCollectionView;

    if (view != null)
    view.RootGroupChanged += new EventHandler(this.DataGridCollectionView_RootGroupChanged);
    base.SetValue(StatContextPropertyKey, view.m_rootGroup);

    I’m using DataGridCollectionViewSource as taken from documentation samples, not DataGridCollectionView. Maybe this is why StatContext is null.

    What I’m doing wrong here ??

    Imported from legacy forums. Posted by Remigiusz (had 978 views)

    User (Old forums)
    Post count: 23064

    Uhh, I found in documentation that “Statistical Functions” subject is marked “Vanguard Only”, could it be a reason ??

    Imported from legacy forums. Posted by Remigiusz (had 538 views)

    Xceed Support
    Post count: 5658

    If you look at your license key in the Xceed Component Licenser, what version of the DataGrid does it say you are using? Free or Pro? If it is Pro, is it a trial?

    If you are using the free license key, you should be getting an exception stating so. If you are using the pro or pro trial, you should be able to use the statistical functions.

    Let me know and I will investigate further.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 503 views)

    Xceed Support
    Post count: 5658

    Do you have anything displayed in the output window in regards to the statcell? If it were a licensing issue, I am pretty sure you would have received an licensing exception.

    I would like you to try binding the Content of the StatCell to the result to see if that changes anything.

    In the meantime, I will try to reproduce the problem here.

    Imported from legacy forums. Posted by Jenny [Xceed] (had 441 views)

    Xceed Support
    Post count: 5658

    We tried to reproduce the behavior you are reporting. Could you send me a repro app to support@xceedsoft.com ?

    Imported from legacy forums. Posted by Jenny [Xceed] (had 284 views)

    User (Old forums)
    Post count: 23064

    This is not licensing problem I think. I created simple project to reproduce this behavior, but in it everything works OK. 🙂
    I will not be available for a week or so. I’ll try to find the key difference between those projects later.

    Imported from legacy forums. Posted by Remigiusz (had 354 views)

    User (Old forums)
    Post count: 23064

    Found it.

    It was those two lines in my user control constructor

    source.ItemProperties.Add(new DataGridItemProperty(TypeDescriptor.GetProperties(typeof(BudgetDS.LinesRow))[“CategoryCode”]));
    source.ItemProperties.Add(new DataGridItemProperty(TypeDescriptor.GetProperties(typeof(BudgetDS.LinesRow))[“FinCode”]));

    If I remove it, StatCell works OK

    I’ll send a solution with reproduction of this bug in a minute.

    Imported from legacy forums. Posted by Remigiusz (had 437 views)

    User (Old forums)
    Post count: 23064

    For all who will have the same problem, after exchanging few mails with support I have solution from Xceed.

    Instead of using source.ItemProperties you should use source.View.ItemProperties.

    source.ItemProperties and source.View.ItemProperties are separate collections and if source.ItemProperties is empty source.View.ItemProperties is used. When I add item to source.ItemProperties datagrid uses only added properties from it and ignores source.View.ItemProperties.

    Imported from legacy forums. Posted by Remigiusz (had 5667 views)

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