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

Changing picker options based on form data

5 Answers 162 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Monty
Top achievements
Rank 1
Monty asked on 14 Feb 2018, 02:29 PM

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?

5 Answers, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 19 Feb 2018, 11:14 AM
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
0
Carl
Top achievements
Rank 1
answered on 30 Sep 2018, 03:42 AM

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.

0
Stefan Nenchev
Telerik team
answered on 03 Oct 2018, 02:40 PM
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
0
Carl
Top achievements
Rank 1
answered on 03 Oct 2018, 03:47 PM
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)
0
Stefan Nenchev
Telerik team
answered on 08 Oct 2018, 10:04 AM
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
Tags
DataForm
Asked by
Monty
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Carl
Top achievements
Rank 1
Share this question
or