Ticket Q337620
Visible to All Users
Duplicate

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 properties

How can i restrict in the Permisssions of certains fields in permissions list

created 14 years ago

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

Show previous comments (1)

    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.

    Anatol (DevExpress) 14 years ago

      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:

      C#
      [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:

      C#
      [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

        Answers

        created 14 years ago

        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

          Show previous comments (3)
          Anatol (DevExpress) 14 years ago

            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

              Anatol (DevExpress) 14 years ago

                You are welcome!
                Thanks,
                Anatol

                Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.