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

EditorAttribute for collections is ignored

3 Answers 97 Views
PropertyGrid
This is a migrated thread and some comments may be shown as answers.
Lukas
Top achievements
Rank 1
Lukas asked on 15 Nov 2018, 01:22 PM

Hi,

 

I have a problem showing the right editor für the properties for items inside a collection.

For RadPropertyGrid.Item I set a collaction.

The items of the collection has some EditorAttribtes set.

But at the ProbpertyGrid the Attribute is ignored.

Is there anything I can do to get this working?

 

    private void Grd_OnSelectedCellsChanged(object sender, GridViewSelectedCellsChangedEventArgs e)
    {
        PropGrid.Item = new List<Test> {new Test {Name = "N1", Number = 1}, new Test {Name = "N2", Number = 1}};
 
    }
 
 
 
public class Test
{
    public string Name { get; set; }
    [Telerik.Windows.Controls.Data.PropertyGrid.Editor(typeof(TextBlock), EditorStyle.Modal)]
    public int Number { get; set; }
}

3 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 20 Nov 2018, 08:28 AM
Hi Lukas,

Looking at the provided code snippet you have applied a collection to the RadPropertyGrid. The control does not support showing properties of the items inside a collection. The RadPropertyGrid can be used for one object only. In your case, you can use the CollectionEditor control. You can read more about this control in the CollectionEditors help article in our documentation.

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Lukas
Top achievements
Rank 1
answered on 20 Nov 2018, 08:40 AM

Hi Dinko,

 

thanks for your reply.

But isn't the PropertySet exactly for that?

Because if I set the PropertySetMode to Intersection or Union I get all the properties from the items of the collection. Also multi edit is working. But the EditorAttribute is ignored.

 

Regards, Lukas

 

0
Dinko | Tech Support Engineer
Telerik team
answered on 22 Nov 2018, 03:12 PM
Hello Lukas,

You are correct that you can use the PropertySetMode property to show the properties of items inside a collection. I have overlooked that and please accept my apologies.

Regarding your scenario. The EditorAttribute is ignored when PropertySetMode is used. Basically, in your case, you have a collection of one and the same objects. But you can set a collection to the PropertyGrid of different objects which have different EditorAttribute set to their properties. There is no built-in logic which can specify which EditorAttribute is more important than the other.

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Al
Top achievements
Rank 1
commented on 28 Sep 2023, 12:24 PM

Hello Dinko,

In regard to Lukas' scenario, is there any way to manually decide which EditorAttribute pick? Or if this is not feasible which should be the correct way to intersect/merge a collection of custom properties?

Regards,
Albino

Martin Ivanov
Telerik team
commented on 29 Sep 2023, 07:11 AM

I am not sure that I understand what you mean by asking how to manually decide which EditorAttribute to pick. Can you elaborate a bit more on this?
The EditorAttribute is applied per property which means that the corresponding editor will be used only with that specific property. Also there is no option in the EditorAttribute that allows selecting an editor based on a condition. In case you want more freedom when it comes to editors, you can use the EditorTemplate.  

If you want to provide a list different objects with intersecting properties, you can check the PropertySetMode.

To provide a custom list properties to be displayed in the PropertyGrid, then you can define the PropertyDefinitions manually

Al
Top achievements
Rank 1
commented on 02 Oct 2023, 07:23 AM

Hello Martin,

I need to use the Property Grid to show the properties of different types of objects, each one with their properties. By giving the possibility to either select just one object and see just its properties or choose two or more objects of the same type and see an intersection of their properties. For some properties I've defined a template and assigned to the properties by using the attribute [Telerik.Windows.Controls.Data.PropertyGrid.Editor(typeof(EditorName))]. If I bind the Property Grid with just an object I can see the properties with the correct EditorTemplate, but if I try to bind it with a collection of objects and using any type of PropertySetMode I will lose the EditorTemplate and any other attributes that I assigned to the properties like [MergeableProperty(false)].

So the question is:

if the problem is during the intersection operation, is there any way for me to customize this function? Or should I do the intersection manually and then give the Property Grid just the merged object?

Otherwise is there any better way to solve my problem?

Regards,

Albino

Martin Ivanov
Telerik team
commented on 03 Oct 2023, 10:20 AM

Hi Albino,

The most convenient way to manually adjust the displayed properties with all their customizations would be to create the PropertyDefinition objects manually when you change the Source value. This way you can check the new value in the Source and based on its type created whatever definitions you need.

Tags
PropertyGrid
Asked by
Lukas
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Lukas
Top achievements
Rank 1
Share this question
or