Best way to make some fields dynamically enabled/disabled?

5 posts, 1 answers
  1. David
    David avatar
    9 posts
    Member since:
    Jul 2011

    Posted 27 Jul 2011 Link to this post

    Firstly, thanks for adding this to the controls - I am working on a project that will have a LOT of property editing and this will be a huge part of the user experience - I love the group/sort, search and description features.

    One issue I have though is that many of my objects have properties that are only meaningful if other properties have certain values - for example in a 'workitem' object, I have a field called 'AssignedTo' but it is not valid (and I would like to grey it out or hide it) if the workitem state is 'completed'.  Can you suggest the best way to go about this?

    PS: any tips on tying this in with Annotations in RIA Services would be appreciated, though it looks like there's no built-in feature there yet.
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 27 Jul 2011 Link to this post

    Hi David,

    This could be achieved via bindings. You may place your own editor in the property grid field and bind its enabled state to a certain property. Please give me a small business object of yours and I will gather a small sample for you. Just let me know which property is to be edited and which one controls the enabled/disabled state.

    All the best,
    Pavel Pavlov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft banner
  4. David
    David avatar
    9 posts
    Member since:
    Jul 2011

    Posted 06 Aug 2011 Link to this post

    Well, even a contrived example will be fine, so let's use...

    public

     

     

    partial class workitem
    {

    private int id;

    private string title;

    private string description;

    private int project_id;

    private int assignee_id;

    private int estimated_remaining_hours;

    private DateTime estimated_eta;

    private int status_id;

    }

    .. and please implement that 'estimated_remaining_hours' and 'estimated_eta fields' are only valid for certain values of status_id (this maps to statuses such as 'open issue', 'workitem completed' etc).

    Greying out would be OK, but even better UI would be to hide irrelevant fields based on some of the parameters. Also it needs to be dynamic, since the user can change the workitem status as they edit the workitem.

    Thanks!

     

  5. Answer
    Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 11 Aug 2011 Link to this post

    Hello David,

    Please find the sample attached . The DateTime field will be disabled when there is a status different from 1 entered in the status field.

    Greetings,
    Pavel Pavlov
    the Telerik team

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

  6. David
    David avatar
    9 posts
    Member since:
    Jul 2011

    Posted 16 Aug 2011 Link to this post

    Thanks - that was helpful!
Back to Top
DevCraft banner