RadPivotFieldList : Custom aggregateDescription removed when unchecked

5 posts, 1 answers
  1. JC
    JC avatar
    16 posts
    Member since:
    Oct 2015

    Posted 01 Mar Link to this post

    Hie 

    I declared all my property description in a LocalDataSourceProvider as below. On the first run it works well, but when I uncheck and re-check my custom property are removed (CustomName and AggregateFunction) and property are not put in the right bow (RowGroupDescription instead of ColumnGroupDescriptions) as shown in the attached file. Does it exist some property to set to not lose custom description ?

                <pivot:LocalDataSourceProvider x:Key="DataSourceProvider" ItemsSource="{Binding SynthesisData}">
                    <pivot:LocalDataSourceProvider.RowGroupDescriptions>
                        <pivot:PropertyGroupDescription PropertyName="ElementName" CustomName="Element Name" />
                        <pivot:PropertyGroupDescription PropertyName="LatticeType" CustomName="Lattice Type" />
                    </pivot:LocalDataSourceProvider.RowGroupDescriptions>
                    <pivot:LocalDataSourceProvider.ColumnGroupDescriptions>
                        <pivot:PropertyGroupDescription PropertyName="JibName" CustomName="Jib Name" />
                        <pivot:PropertyGroupDescription PropertyName="Type" />
                    </pivot:LocalDataSourceProvider.ColumnGroupDescriptions>
                    <pivot:LocalDataSourceProvider.AggregateDescriptions>
                        <pivot:PropertyAggregateDescription PropertyName="Percentage" CustomName="Base %" AggregateFunction="Max" StringFormat="#.00\%" />
                        <pivot:PropertyAggregateDescription PropertyName="ModifiedPercentage" CustomName="Ruled %" AggregateFunction="Max" StringFormat="#.00\%"/>
                        <pivot:PropertyAggregateDescription PropertyName="Radius" CustomName="Radius" StringFormat="#.00 m"  AggregateFunction="Max"/>
                    </pivot:LocalDataSourceProvider.AggregateDescriptions>
                </pivot:LocalDataSourceProvider>
     
    ...
     
    <pivot:RadPivotGrid x:Name="Pivot" Margin="8,8,292,7.565" DataProvider="{StaticResource DataSourceProvider}" ColumnSubTotalsPosition="Right">
                <pivot:RadPivotGrid.RowGroupsExpandBehavior>
                    <pivot:GroupsExpandBehavior Expanded="False" />
                </pivot:RadPivotGrid.RowGroupsExpandBehavior>
                <pivot:RadPivotGrid.ColumnGroupsExpandBehavior>
                    <pivot:GroupsExpandBehavior Expanded="False" />
                </pivot:RadPivotGrid.ColumnGroupsExpandBehavior>
            </pivot:RadPivotGrid>
     
            <pivot:RadPivotFieldList Grid.Row="0" Margin="0,8,8,7.565" HorizontalAlignment="Right" Width="283" DataProvider="{StaticResource DataSourceProvider}" />

     

  2. Polya
    Admin
    Polya avatar
    200 posts

    Posted 02 Mar Link to this post

    Hello,

    When a checkbox for a field is checked in the RadPivotFieldList a default description is created for this field and is placed in its default role (rows, columns, values, filters). For numeric values a PropertyAggregateDescritpion is created with its default AggregateFunction - Sum and is added in "Values" as this is its default role.
    That is why the fields can be dragged from the RadPivotFieldList list part to a specific role - this way the users can place a numeric field in "Rows", for example. However, the default role for a field cannot be changed with the current implementation of RadPivotGrid.

    If you wish to create a custom description when a field is being added you can add handler to the DataProvider.PrepareDescriptionForField event and modify the description. You can find more information about this event here: http://docs.telerik.com/devtools/wpf/controls/radpivotgrid/events/overview

    In your scenario for the field Radius you can use this event and modify the PropertyAggregateDescription for it with CustomName = "Radius" and AggregateFunction - Max using this code:
    private void LocalDataSourceProvider_PrepareDescriptionForField(object sender, PrepareDescriptionForFieldEventArgs e)
    {
        var radiusDescription = e.Description as PropertyAggregateDescription;
        if (radiusDescription.PropertyName == "Radius")
        {
            radiusDescription.CustomName = "Radius";
            radiusDescription.AggregateFunction = new MaxAggregateFunction();
        }
    }

    Hope this helps.

    Regards,
    Polya
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. JC
    JC avatar
    16 posts
    Member since:
    Oct 2015

    Posted 04 Mar in reply to Polya Link to this post

    Hello Polya

    Thanks for your quick answer.

    It works well for CustomName, stringFormat, aggregateFunction and all properties (see code below).

    Private Sub DataSourceProvider_OnPrepareDescriptionForField(sender As Object, e As PrepareDescriptionForFieldEventArgs)
      Dim agregateDescription As PropertyAggregateDescription = TryCast(e.Description, PropertyAggregateDescription)
      Dim groupeDescription As PropertyGroupDescription = TryCast(e.Description, PropertyGroupDescription)
     
      If (groupeDescription IsNot Nothing) Then
        Select Case groupeDescription.PropertyName
          Case "ElementName"
            groupeDescription.CustomName = "Element Name"
          Case "LatticeType"
            groupeDescription.CustomName = "Lattice Type"
          Case "JibName"
            groupeDescription.CustomName = "Jib Name"
          Case "Type"
            groupeDescription.CustomName = "Type"
          Case Else
        End Select
      ElseIf (agregateDescription IsNot Nothing) Then
        Select Case agregateDescription.PropertyName
          Case "Percentage"
            agregateDescription.CustomName = "Base %"
            agregateDescription.StringFormat = "#.00\%"
            agregateDescription.AggregateFunction = New MaxAggregateFunction()
          Case "ModifiedPercentage"
            agregateDescription.CustomName = "Ruled %"
            agregateDescription.StringFormat = "#.00\%"
            agregateDescription.AggregateFunction = New MaxAggregateFunction()
          Case "Radius"
            agregateDescription.CustomName = "Radius"
            agregateDescription.AggregateFunction = New MaxAggregateFunction()
          Case Else
        End Select
      End If
    End Sub

    But I still got a problem to determine rowGroupDescriptions and columnGroupDescriptions. As i described it on my first post I put ElementName and LatticeType into RowGroupDescriptions and JIbName and Type into ColumnGroupDescriptions, but when I uncheck and re-check, JibName and Type are not put into the columnGroupDescriptions but into the rowGroupDescriptions.

    regards

    J-Christophe

  5. Answer
    Polya
    Admin
    Polya avatar
    200 posts

    Posted 07 Mar Link to this post

    Hi J-Christophe,

    I am glad the proposed approach helped achieve the desired.

    Regarding the fields added in rows instead of columns - in order to achieve the desired we need to change the PreferredRole of the "JibName" and "Type" fields. We can use the AddingContainerNode event of the LocalDataSourceFieldDescriptionsProvider. You can find more information about it in this help article:
    http://docs.telerik.com/devtools/wpf/controls/radpivotgrid/events/overview and an example demonstrating how to use it in our developer focused examples: https://github.com/telerik/xaml-sdk/tree/master/PivotGrid/CustomizeFieldTree.

    For your the handler should look something like that:
    <pivot:LocalDataSourceProvider x:Key="DataProvider" ItemsSource="{Binding}">
    <!-- .......... -->
        <pivot:LocalDataSourceProvider.FieldDescriptionsProvider>
            <pivot:LocalDataSourceFieldDescriptionsProvider AddingContainerNode="LocalDataSourceProvider_AddingContainerNode"/>
        </pivot:LocalDataSourceProvider.FieldDescriptionsProvider>
    </pivot:LocalDataSourceProvider>

    private
    void LocalDataSourceProvider_AddingContainerNode(object sender, Telerik.Pivot.Core.Fields.ContainerNodeEventArgs e)
    {
        if (e.ContainerNode.Name == "JibName" || e.ContainerNode.Name == "Type")
        {
            FieldInfoNode fin = e.ContainerNode as FieldInfoNode;
            (fin.FieldInfo as PropertyFieldInfo).PreferredRole = FieldRoles.Column;
        }
    }

    Hope this helps.

    Regards,
    Polya
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  6. JC
    JC avatar
    16 posts
    Member since:
    Oct 2015

    Posted 07 Mar in reply to Polya Link to this post

    thanks a lot it works.
Back to Top
UI for WPF is Visual Studio 2017 Ready