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

Edit dictionary property in RadPropertyGrid

4 Answers 222 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Yaniv
Top achievements
Rank 1
Yaniv asked on 26 Oct 2014, 02:10 PM
Hi,
I'm using this really great control of RadPropertyGrid to generate grids dynamically for several types of objects.
Lately, I tried to add object with property of dictionary (i.e. Dictionary<int, string> and no success on this try...

What should I do?

See my example at property called ItemsData (which is Dictionary<long, string>)

4 Answers, 1 is accepted

Sort by
0
Yaniv
Top achievements
Rank 1
answered on 26 Oct 2014, 03:40 PM
Ok, it seems to be working... 
I just needed to initialize the Dictionary.
But now, I see that I can't add new pair to the dictionary (the add button is disabled) and on pressing remove I get an exception.
Also, I tried to use dictionary with custom type (i.e. Dictionary<int, Customer> and I couldn't edit the custom type.

So my questions are:
1 - How can I make the "add" and "Remove" buttons work safely?
2 - Can I just write a custom control for those kind of complicated properties within the RadPropertyGrid?


0
Maya
Telerik team
answered on 28 Oct 2014, 02:03 PM
Hi Yaniv,

Generally, add and remove buttons will be enabled if: 
1. There is a default (parameterless) constructor of your business object.
2. The source collection should support add/remove methods.

My recommendation is to try working with another collection and ensure that there is a default constructor. 



Regards,
Maya
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Yaniv
Top achievements
Rank 1
answered on 29 Oct 2014, 01:27 PM
Thanks, I understood that.
But generally, It looks like this control doesnt support properties of type Dictionay.
I managed to write a List class that implements the IDictionary to make it work and it works good only if the Dictionary has primitive types only. Doesn't work for Dictionary that holds custom class. While collection with custom class works good :-\

Any suggestion?
0
Maya
Telerik team
answered on 03 Nov 2014, 08:34 AM
Hello Yaniv,

I attach a sample project with a simple property grid holding object with a property of collection type. Could you update it so that it corresponds to your exact scenario and I can debug it on my side ? 
You can either paste the code I need to add here (if it is not too much) or update directly the project and send it to me via support ticket. 


Regards,
Maya
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Yaniv
Top achievements
Rank 1
Answers by
Yaniv
Top achievements
Rank 1
Maya
Telerik team
Share this question
or