RadDataForm ReadOnly Object

8 posts, 1 answers
  1. Titus
    Titus avatar
    6 posts
    Member since:
    Dec 2008

    Posted 02 Feb 2012 Link to this post

    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

  2. Answer
    Maya
    Admin
    Maya avatar
    4062 posts

    Posted 03 Feb 2012 Link to this post

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

  3. DevCraft banner
  4. Titus
    Titus avatar
    6 posts
    Member since:
    Dec 2008

    Posted 03 Feb 2012 Link to this post

    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

  5. jen
    jen avatar
    63 posts
    Member since:
    Jun 2009

    Posted 17 Jan 2013 Link to this post

    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?
  6. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 22 Jan 2013 Link to this post

    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.

  7. Eric
    Eric avatar
    2 posts
    Member since:
    Feb 2013

    Posted 02 May 2013 Link to this post

    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.
  8. jen
    jen avatar
    63 posts
    Member since:
    Jun 2009
  9. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 07 May 2013 Link to this post

    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.

Back to Top
DevCraft banner