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

RadDataForm ReadOnly Object

7 Answers 60 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Titus
Top achievements
Rank 1
Titus asked on 02 Feb 2012, 08:49 AM
I am trying to use RadDataForm to edit a collection of business object. The business object has a property IsEditable. If this is true, then the object can be edited otherwise it cannot be edited.

Is there a way I can disable the edit command button based on this property value of the current item in the collection. i.e. I want the edit command button to be enabled or disabled (based on this property) as I navigate through the collection.

I understand I can achieve the readonly mode by making the controls readonly in the EditTemplate based on this property. However, this would be tedious as there are too many controls in the form. Also, user clicking the edit button and not being able to edit (as the object is readonly) does not make a good user experience.

Just want to know if there is a simpler way other than changing the edit template.

Thanks and Regards,
Titus

7 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 03 Feb 2012, 03:16 PM
Hello Titus,

You can try implementing this functionality in your ViewModel. For example:
1. Bind CurrentItem property of RadDataForm to a property in the ViewModel;
2. Once this property is changed, you can verify its property value (containing the information for read-only mode of the item) and based on it to disable/enable a custom command defined in this ViewModel.
3. Bind the Command of the Edit-Button to this custom command in your ViewModel.

Will that scenario correspond to your needs ?  

Regards,
Maya
the Telerik team

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

0
Titus
Top achievements
Rank 1
answered on 03 Feb 2012, 07:45 PM
Thanks for the quick response.

Yes it will.

I was looking to see if there is any way I can bind a property of RadDataForm to a boolean property on my Entity object to disable the edit button.

I wasn't looking to implement MVVM as the project I am working on is a prototype and was not planning to use View Models.

I guess I will use View Model.

Thanks
Titus

0
jen
Top achievements
Rank 1
answered on 17 Jan 2013, 03:18 PM
I have the same situtation. Some of the items in my collection are not allowed to be edited, I need the edit button to remain disabled when these items are seleected.

Can you provide and example of how to do step #3 above?
"3. Bind the Command of the Edit-Button to this custom command in your ViewModel."

I can make my own command in the view model, but how do I hook it up to the edit button?
0
Ivan Ivanov
Telerik team
answered on 22 Jan 2013, 04:40 PM
Hi,

You should modify RadDataForm's template, find the button and bind its Command and CommandParameter properties to the respective members of your ViewModel. Unfortunately, this is quite a unnatural approach, so we have planned to make this task achievable through the API with Q2.

All the best,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Eric
Top achievements
Rank 1
answered on 02 May 2013, 09:10 PM
Please post an example of how to find the button and bind its command and command parameter, as there are none dealing with the edit button or any of the buttons for that matter in the documentation.
0
jen
Top achievements
Rank 1
answered on 06 May 2013, 01:51 PM
0
Ivan Ivanov
Telerik team
answered on 07 May 2013, 10:46 AM
Hello Guys,

 Thank you, Jen. Here is an additional running example.

All the best,
Ivan Ivanov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
DataForm
Asked by
Titus
Top achievements
Rank 1
Answers by
Maya
Telerik team
Titus
Top achievements
Rank 1
jen
Top achievements
Rank 1
Ivan Ivanov
Telerik team
Eric
Top achievements
Rank 1
Share this question
or