Change AllowedRoles

4 posts, 0 answers
  1. Thomas
    Thomas avatar
    6 posts
    Member since:
    Jan 2015

    Posted 23 Jun 2015 Link to this post

    Hello, 

    How can I change the AllowedRoles of Fields in a Pivotgrid.

    Best regards

    Thomas

  2. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    712 posts

    Posted 24 Jun 2015 Link to this post

    Hello Thomas,

    Thank you for writing.

    This property has a private setter, so you would need reflection in order to change it:
    IPivotFieldInfo myFieldInfo = this.radPivotFieldList1.ViewModel.Fields[1].FieldInfo;
    if (myFieldInfo != null)
     {
         PropertyInfo pi = myFieldInfo.GetType().GetProperty("AllowedRoles", BindingFlags.Public | BindingFlags.Instance);
         {
             if (pi != null)
             {
                 FieldRoles myRole = FieldRoles.Column;
                 pi.SetValue(myFieldInfo, myRole);
             }  
         }
     }

    If you provide me with additional information of what exactly you are trying to accomplish, perhaps we could also find a different solution.

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    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 WinForms is Visual Studio 2017 Ready
  4. Thomas
    Thomas avatar
    6 posts
    Member since:
    Jan 2015

    Posted 24 Jun 2015 in reply to Hristo Merdjanov Link to this post

    Hello Hristo Merdjanov,

     I want to dynamically fill a Pivotgrid with fields defined in a datatable.
    Here I want to define the important Informations:

    1. Datafield
    2. Sortfield for a sorting different from the datafield
    3. Define the Allowed Roles (R=Rowgroup, C=Columngroup, V=Value, F=Filter)
    4. Define the prefered Role
    5. Prefered Aggregate

    I can't define the Fieldinfo so I had to generate a dynamic SQL Command to only get the Fields i wanted.
    Reflection is a Solution but not really a good one. The ebst wouöd be to have a Editor to define the fieldinfo.
    AutogenerateFields=false together with a FieldInfoCollection.

    Thank You for your answer.

    Best regards

    Thomas

     

  5. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    712 posts

    Posted 29 Jun 2015 Link to this post

    Hi Thomas,

    Thank you for writing back.

    The scenario, as you describe it, interferes with the internal mechanism of how RadPivotGrid works. There is no exposed API to allow such modifications and all these members are being set privately and depend on numerous factors. Modifying them outside of their internal environment would not be possible as this will obstruct the way how the view model passes data between the view and the models.

    Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    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
Back to Top