External "CancelEdit()"

6 posts, 0 answers
  1. Heiko
    Heiko avatar
    124 posts
    Member since:
    Oct 2012

    Posted 02 Apr 2012 Link to this post

    Hi Telerik-Team!

    We are evaluating RadDataForm (2012.1) using an MVVM approach. The DataForm is bound to a QueryableDomainServiceCollectionView (QDSCV) on the ViewModel, Navigation/New/Edit/Delete buttons are visible, OK/Cancel buttons are hidden. When clicking on the Edit-Button the RadDataForm goes into Edit-Mode - so far, so fine. We now have a separate button outside the DataForm which when clicked does a QDSCV.CancelEdit(). Even though the QDSCV has no more CurrentEditItem still the RadDataForm is displaying data in Edit-Mode. How can we force RadDataForm to cancel edit? Remember we are using the MVVM pattern so we don't want to use methods on the control directly.

    Regards
    Neils
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 02 Apr 2012 Link to this post

    Hi Neils,

    You can try using CancelEdit command placed in RadDataFormCommands class.  

    All the best,
    Maya
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. DevCraft banner
  4. Heiko
    Heiko avatar
    124 posts
    Member since:
    Oct 2012

    Posted 02 Apr 2012 Link to this post

    Thanks for your quick response. This is true if I only have one RadDataForm. Our scenario is slightly different. We have a person-entity which has a list of addresses and a list of phonenumbers. Addresses and phonenumbers are bound to separate RadDataForms whereas the person-entity is simply bound to textboxes. We want to have buttons for Save and Cancel and no OK/Cancel buttons on each RadDataForm. As far as I know a button can only be bound to one Command. Here we have two commands on each RadDataForm.

    Regards
    Neils
  5. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 02 Apr 2012 Link to this post

    Hello Neils,

    Indeed, you can use only a single command for a button. Could you clarify what is the current implementation of your command ? 
    Generally, you can create a custom command in your ViewModel and perform all the actions you want in its Execute method. Thus you could be able to use your own custom logic as well as implementing the CancelEdit command of the data form. 

    Greetings,
    Maya
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  6. Heiko
    Heiko avatar
    124 posts
    Member since:
    Oct 2012

    Posted 02 Apr 2012 Link to this post

    Our cancel button is just bound to a DelegateCommand on the ViewModel. I don't see a way to call CancelEdit on the RadDataForm from the execute method of this cancel button without having a reference to the RadDataForm itself (which is against the MVVM pattern).

    Best regards
    Neils
  7. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 05 Apr 2012 Link to this post

    Hi Neils,

    Indeed, you are correct, I misled you in suggesting to work with the CancelEdit command of the data form as you will need a reference to it. What you can try instead is to create custom UserControl, place the button inside and perform the logic for canceling editing of the data form and the source collection inside.
    Nevertheless, we will definitely consider improving the behavior and research the possibility for exposing the commands of the data form.   

    All the best,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top
DevCraft banner