I'm using the control in two places. In one of them things are working fine. In the other, AddNewItem() is returning false.
Clearly I am doing something wrong, but I'm having the hardest time figuring out what.
Is there anyplace I could look to figure out exactly why AddNewItem() is deciding not to add a new item? Is there some way of turning on some sort of logging trace?
5 Answers, 1 is accepted
Generally, the ability to add and remove items depends on your source collection and the implementation of your business object. You need to have data source that you can insert new items into - like List, ObservableCollection, etc. and you need to have a default constructor in the implementation of your business object. Will it be possible to check whether those criteria are met ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Like I said, this control is allowing new items in one place where it is used, it is not in another. My guess is that I simply have it bound to the wrong object. When I get done with dealing with today's crisis, I'll be adding a do-nothing IValueConverter, so I can add a breakpoint in the debugger and see exactly what is being bound.
Still, in general, I think it would be a good idea if the Telerik controls would report, via Visual Studio's debugging and tracing mechanisms, something about why it is deciding to do certain things.
A message like "AddNewItem() failed because object foo does not support bar" would go a long way towards figuring out these sorts of problems,
Actually, it is a bit beyond the functionality of the control to throw exceptions about its underlying collections and business objects (in case it is for validation). The ability to insert and remove items is not directly provided by the control - it actually counts on the source and the business object for doing so. Will it be possible to test the case where you cannot add new item with another control - RadGridView, DataGrid, ListBox, etc. in order to verify whether the problem is with RadDataForm and not with the source ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
But as for the providing of an error trace - I understand that it's the collection that is responsible for adding and removing items. But AddNewItem() isn't throwing an exception, it's returning false. That means it's either using reflection to determine whether ItemsSource has an Add() method, or it's trying to call Add(), getting an exception and throwing it away, or both. It is the ItemsSource object that is responsible for adding new items to the collection, but it's AddNewItem() that is telling it to do so, and it's AddNewItem() that knows that it failed. And whatever information AddNewItem() has about that failure is being thrown away.
And that information, if provided to the developer, through VS's DEBUG and TRACE capabilities, would make it easier to understand what is failing, when things aren't hooked up correctly.
Thank you for the feedback. We will check out to see whether this behavior could be improved.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.