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

External "CancelEdit()"

5 Answers 159 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Heiko
Top achievements
Rank 1
Iron
Veteran
Heiko asked on 02 Apr 2012, 08:10 AM
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

5 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 02 Apr 2012, 08:15 AM
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 >>
0
Heiko
Top achievements
Rank 1
Iron
Veteran
answered on 02 Apr 2012, 08:55 AM
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
0
Maya
Telerik team
answered on 02 Apr 2012, 09:24 AM
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 >>
0
Heiko
Top achievements
Rank 1
Iron
Veteran
answered on 02 Apr 2012, 10:36 AM
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
0
Maya
Telerik team
answered on 05 Apr 2012, 09:53 AM
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 >>

Tags
DataForm
Asked by
Heiko
Top achievements
Rank 1
Iron
Veteran
Answers by
Maya
Telerik team
Heiko
Top achievements
Rank 1
Iron
Veteran
Share this question
or