New button disabled and Cancel button (while editing) disabled

7 posts, 1 answers
  1. Marcelo
    Marcelo avatar
    40 posts
    Member since:
    Jul 2011

    Posted 24 Aug 2011 Link to this post

    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.
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 25 Aug 2011 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Marcelo
    Marcelo avatar
    40 posts
    Member since:
    Jul 2011

    Posted 25 Aug 2011 Link to this post

    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?

  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 25 Aug 2011 Link to this post

    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 >>

  6. Marcelo
    Marcelo avatar
    40 posts
    Member since:
    Jul 2011

    Posted 25 Aug 2011 Link to this post

    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.
  7. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 26 Aug 2011 Link to this post

    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 >>

  8. Marcelo
    Marcelo avatar
    40 posts
    Member since:
    Jul 2011

    Posted 29 Aug 2011 Link to this post

    Thanks a lot for all your help.
Back to Top
UI for WPF is Visual Studio 2017 Ready