Description
Binding RadioGroup can be problematic because its value in the form of object: {name:value}
. The problem is more pronounced if we want to bind radio group to model instance field and the field stores primitive values.
The solution is to use formulas to transform objects from radio groups to primitive values that can be stored in model fields and vice versa primitive values from fields to objects that can be consumed by radio groups.
Main Features
- view model
links
config option loads one record from the server - the record servers as data source
- formulas create
gender
view model property for binding to radio group - formulas implement the transformation logic between radio group and model instance (record)
- record field
gender
is directly bound to the combo to show that the formulas logic works as expected
Use Cases
This approach is useful when a model field can contain only a couple of distinct values and we want the user to select one of them in a radio group.
Example Files (relative to example root)
The example has been initially generated with sencha generate app
. The following list contains only relevant files:
app/view/MainModel.js app/view/Main.jsIf you want to see the example code, login or sign-up. Free membership is available.
I'm a well seasoned developer, consultant and educator of web applications based mainly on Sencha libraries, PHP, MySQL and Node.js. Besides (Apple) computers, I love photography and mountain biking.
Follow me:
Latest posts by saki (see all)
- Ext, Angular, React, and Vue - 27. June 2019
- The Site Resurgence - 11. February 2018
- Configuring ViewModel Hierarchy - 19. June 2015