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

New button disabled and Cancel button (while editing) disabled

6 Answers 249 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Marcelo
Top achievements
Rank 1
Marcelo asked on 24 Aug 2011, 08:44 PM
I am implementing a RadDataForm and even though the data binds, the New button is disabled and the Cancel button (while editing) is disabled also.

I have tried creating Templates (with AutoGenerateFields="False") but it did not make a difference.

6 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 25 Aug 2011, 07:28 AM
Hello Marcelo,

The functionality for inserting new items and discarding the changes depends entirely on the type of the data source. What is the collection you bind your data form to ? 
You can also run through our online documentation for a reference on how to bind the data form.

 

Best wishes,
Maya
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Marcelo
Top achievements
Rank 1
answered on 25 Aug 2011, 01:16 PM
Hello Maya. I have read the docs and for example, at the bottom of this page http://www.telerik.com/help/wpf/raddataform-getting-started.html shows the Add button enabled when the data is bound to an ObservableCollection. I have tried this and also binding the data to a List and I don't get this functionality.

Also, going thru the docs, I did not find a "section" that talks about how different data sources will behave. Can you please help out?

0
Maya
Telerik team
answered on 25 Aug 2011, 03:49 PM
Hello Marcelo,

Generally, the behavior of the data form according to the different types of data source would be the same as to all the other controls. For example if a collection does not support insertion of new items, you will not be able to add one neither with RadDataForm, nor with RadGridView or RadTreeListView for example. 
I am sending you a sample project illustrating how you may insert a new item when the RadDataForm is bound to an ObservableCollection. If you want to support reverting of the changes made, you need to implement IEditableObject Interfaced as mentioned in the documentation.
Let me know in case you need any additional assistance.

All the best,
Maya
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Marcelo
Top achievements
Rank 1
answered on 25 Aug 2011, 06:32 PM
Hello Maya and thank you for the sample you sent me (I remember seeing it in the on-line docs).

I found my problem and the way I see it, it has nothing to do with the type of the data source. When I hear/read "type of the data source" I immediately think of a Data Type, like List, ObservableCollection, Dictionary etc. The problem was the way I had defined the base class, which had one constructor that expected all the fields to be passed in (as opposed to an empty constructor)

Bad constructor

public Task(string name, string description)
{
    this.Name = name;
    this.Description = description;
}

Good constructor

public Task()
{
}

In fact, the collection type can be of List type or ObservableCollection type and it works fine either way, the Add function that is. So the problem was the Constructor in the base class, not the collection nor the collection data type. Now that I think about this it makes sense but this did not click yesterday while looking at this problem. What I need to look into now is implementing the IEditableObject interface to allow the "cancel" operation.

I am going to post my code sample once I have it worknig.
0
Accepted
Maya
Telerik team
answered on 26 Aug 2011, 04:07 PM
Hi Marcelo,

Indeed, if no default constructor is available, insertion of an item will not be possible. I should have mentioned it before. Still, I am really happy to see that you found the cause of the problem. Please let me know in case you need any further assistance.
 

Best wishes,
Maya
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Marcelo
Top achievements
Rank 1
answered on 29 Aug 2011, 01:58 PM
Thanks a lot for all your help.
Tags
DataForm
Asked by
Marcelo
Top achievements
Rank 1
Answers by
Maya
Telerik team
Marcelo
Top achievements
Rank 1
Share this question
or