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>)
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
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?
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
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
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?
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
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
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.