Changing picker options based on form data

6 posts, 0 answers
  1. Monty
    Monty avatar
    1 posts
    Member since:
    Jan 2018

    Posted 14 Feb 2018 Link to this post

    I have a form with a field that contains predefined options, however some of these options are not valid when another field in the form has certain data. Eg, I don't want to give the user the option to set their occupation as retired, when their age is below 30.

    Following the documentation, I thought this would be possible by querying the form data source within the PropertyDataSourceProvider's GetSourceForKey method. While this works initially, it doesn't get called again until the form is manually reloaded.

    My question is, is there a means to recalculate the options available for a field when data is committed back to the form's data source, or when validation is run?

    Calling Reload on the form would probably do the job, but seems like overkill, and isn't very performant. 

    Validating the field based on the form data is another option, but this is pretty rubbish UX - why give the user the option to choose an item if it is instantly marked as invalid when chosen?

  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    663 posts

    Posted 19 Feb 2018 Link to this post

    Hello, Monty,

    Thank you for the detailed explanation of your scenario.

    Indeed, the requirement you have is not very straight-forward to achieve with the way the RadDataForm control is designed. Currently, the control relies on DataAnnotations and/or custom MetadataProvider to control the appearance of the properties. This makes it not very useful in a scenario where run-time modifications are required. Furthermore, currently the control does not support two-way source binding. We have this task logged at our Ideas & Feedback portal and, as you can see, lots of customers have expressed their wish for the control to have such functionality. You can track it at this link - DataForm: Two way Source binding. I have further increased the item's priority as per your request(we plan to introduce it with some of the upcoming releases as its priority is very high).

    If you have any further questions or concerns, do not hesitate to contact us.

    Have a great week.

    Regards,
    Stefan Nenchev
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Carl
    Carl avatar
    17 posts
    Member since:
    Sep 2018

    Posted 29 Sep 2018 in reply to Stefan Nenchev Link to this post

    According to the link this is was already shipped in R2 2018, but I can't find any examples about how this works.

    I've an scenario where I need to dynamically fill the source of a PickerEditor depending on other Picker's selected item (basically a cascading dropdown), is this possible now? Please an example.

  4. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    663 posts

    Posted 03 Oct 2018 Link to this post

    Hello, Carl,

    Unfortunately, the scenario you have is still not supported, even though we have introduced the two-way data binding functionality for the Android and iOS platforms. Basically, in the case of having a picker editor, you are using a UserPropertyDataSourceProvider that provides the source for the picker which represents the specific property. Currently, you need to reload the DataForm in order to reevaluate this property and set a different list as a source depending on some condition. Here is the feedback item which we have logged for supporting dynamic updates  - 
    DataForm: Enable and Disable Editor Dynamically. I have increased its priority as per your request and have added the scenario you are looking for so we can have it in mind when considering the item.

    Have a great rest of the week.

    Regards,
    Stefan Nenchev
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. Carl
    Carl avatar
    17 posts
    Member since:
    Sep 2018

    Posted 03 Oct 2018 in reply to Stefan Nenchev Link to this post

    Stefan, could you please provide a working sample of how to handle my scenario with the current version of DataForm (even if it is needed to reload the view I would like to see how to do it)
  6. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    663 posts

    Posted 08 Oct 2018 Link to this post

    Hi, Carl,

    I have attached a sample that shows how you can achieve the behavior. I hope it will be helpful.

    Have a great week.

    Regards,
    Stefan Nenchev
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top