Hi
i hope all your team is well.
I want to restrict in the list of type of objects some fields in the "Permission window". How can we do that.
Please see the image in attchement.
Thank you
We have closed this ticket because another page addresses its subject:
How to hide or filter out certain types from the drop-down editor for the System.Type propertiesHow can i restrict in the Permisssions of certains fields in permissions list
Answers
Hello Toufik,
I have found that currently this solution is not supported. Please accept my apologies for the incorrect suggestion. An alternative solution is to customize the TypePropertyEditor used to show the ObjectType field's control, as shown below:
Visual Basic<PropertyEditor(GetType(Type), EditorAliases.TypePropertyEditor, True)> _
Public Class MyTypePropertyEditor
Inherits TypePropertyEditor
Public Sub New(ByVal objectType As Type, ByVal model As IModelMemberViewItem)
MyBase.New(objectType, model)
End Sub
Protected Overrides Function IsSuitableType(ByVal type As Type) As Boolean
Return type IsNot GetType(DemoTask) AndAlso MyBase.IsSuitableType(type)
End Function
End Class
Please refer to the Implement Custom Property Editors help topic for additional information.
Thanks,
Anatol
Hello Toufik,
In this code, a custom property editor is implemented. Please refer to the PropertyEditor Class help topic to learn more about property editors.
In the PropertyEditor attribute of this class, the first parameter defines the type for which this editor will be used. I.e. it will be used for properties of the Type type (such as ObjectAccessPermission.ObjectType). The last parameter defines that this property editor will be used for all properties of the passed type. The Implement Custom Property Editors help topic describes this in greater detail.
The IsSuitableType method of the base TypePropertyEditor is called before adding an item that represents a certain type to the editor's dropdown. Thus, to avoid the adding of a certain item, it is required to override the IsSuitableType method and return False in the required case. In my sample, this method is implemented to remove the DemoTask item from the dropdown.
Thanks,
Anatol
Hi Anatol,
Thank you, now i have understand with your sample and the explanation…!!
Thank you vey much
Hello Toufik,
I am afraid that there is no easy way to filter this list based on a user. It is not quite clear why you need this functionality. From my point of view, simple users should not be able to modify and grant permissions at all. Please describe your scenario in greater detail.
Thanks,
Anatol
Hi,
You are right, in fact it was for the administrator him even so that he does not mix too much. I thought that this list could be reduced to the class's only ones of the project.
Thank you very much, in any case.
Hello Toufik,
If it is it not required to change the filter of the types list depending on the user, there is a solution to your task.
A collection of possible types and captions for them is defined in the PermissionTargetBusinessClassListConverter class, that is applied to the ObjectAccessPermission.ObjectType property via the following code:
[TypeConverter(typeof(PermissionTargetBusinessClassListConverter))] public Type ObjectType {
You can create a descendant of this type converter, and override its GetStandardValues method to remove required values from the list. Then, create a descendant of the ObjectAccessPermission class, and implement a second Type property in it, as shown in the following code:
[TypeConverter(typeof(MyPermissionTargetBusinessClassListConverter))] public Type Type { get { return ObjectType; } set { ObjectType = value; } }
Then, hide the ObjectType property from views of the newly created ObjectAccessPermission descendant via the Model Editor, and use the Type property instead.
Thanks,
Anatol
Thank you Anatol,
have you a sample of simple code about this ?
I don't see very well how i can do…
Thank you again and hope i do not disturb yo…
PS: Sir Denis has answer me