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

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

    I have UserControl defined in xaml

    <UserControl
    xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation&#8221;
    xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml&#8221;
    x:Class=”ADB.SDA.ADBBudget.GUI.CategoryView”
    xmlns:xcdg=”http://schemas.xceed.com/wpf/xaml/datagrid”&gt;
    <UserControl.Resources>
    <xcdg:DataGridCollectionViewSource x:Key=”viewsource” Filter=”source_Filter”
    Source=”{Binding Source={StaticResource dataset}, Path=Lines}”>
    <xcdg:DataGridCollectionViewSource.StatFunctions>
    <xcdg:SumFunction ResultPropertyName=”month2_sum” SourcePropertyName=”Month2″/>
    </xcdg:DataGridCollectionViewSource.StatFunctions>
    </xcdg:DataGridCollectionViewSource>
    </UserControl.Resources>
    <xcdg:DataGridControl ItemsSource=”{Binding Source={StaticResource viewsource}}” AutoCreateColumns=”False” ReadOnly=”True”>
    <xcdg:DataGridControl.View>
    <xcdg:TableView>
    <xcdg:TableView.FixedHeaders>
    <xcdg:ClearHeadersFooters/>
    <DataTemplate>
    <xcdg:ColumnManagerRow/>
    </DataTemplate>
    </xcdg:TableView.FixedHeaders>
    <xcdg:TableView.Theme>
    <xcdg:LunaMetallicTheme/>
    </xcdg:TableView.Theme>
    <xcdg:TableView.GroupLevelConfigurations>
    <xcdg:ClearGroupLevelConfigurations/>
    <xcdg:GroupLevelConfiguration>
    <xcdg:GroupLevelConfiguration.Footers>
    <xcdg:GroupHeaderFooterItemTemplate VisibleWhenCollapsed=”True”>
    <DataTemplate>
    <xcdg:StatRow Background=”AliceBlue”>
    <xcdg:StatCell FieldName=”Month2″ ResultPropertyName=”month2_sum” Background=”Yellow”/>
    </xcdg:StatRow>
    </DataTemplate>
    </xcdg:GroupHeaderFooterItemTemplate>
    </xcdg:GroupLevelConfiguration.Footers>
    </xcdg:GroupLevelConfiguration>
    <xcdg:GroupLevelConfiguration/>
    </xcdg:TableView.GroupLevelConfigurations>
    </xcdg:TableView>
    </xcdg:DataGridControl.View>
    <xcdg:DataGridControl.Columns>
    <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″/>
    </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>
    </UserControl>

    and in code behind

    public partial class CategoryView
    {
    public CategoryView()
    {
    InitializeComponent();
    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”];
    source.View.Refresh();
    }

    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);
    }
    else
    {
    base.ClearValue(StatContextPropertyKey);
    }

    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)
    Member
    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
    Member
    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
    Member
    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
    Member
    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)
    Member
    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)
    Member
    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)
    Member
    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.

    Reason:
    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.