This is a migrated thread and some comments may be shown as answers.

Change AllowedRoles

3 Answers 130 Views
PivotGrid and PivotFieldList
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 23 Jun 2015, 07:54 PM

Hello, 

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

Best regards

Thomas

3 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 24 Jun 2015, 01:48 PM
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
0
Thomas
Top achievements
Rank 1
answered on 24 Jun 2015, 06:55 PM

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

 

0
Hristo
Telerik team
answered on 29 Jun 2015, 02:41 PM
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
Tags
PivotGrid and PivotFieldList
Asked by
Thomas
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or