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