BackgroundThe MatrixLookup behavior sets a form element value based on a Matrix Lookup. For example, assume a Matrix named 'Consultant Rates': Consultant | Activity | Rate | | | 125.00 | bo@whitehouse.gov |
| 400.00 | | DB Tuning | 200.00 | | Project Management | 175.00 | jdoe@quandis.com | Project Management | 150.00 |
From here, we can create a form containing a Consultant dropdown list, an Activity dropdown list, and a Rate text box:
<form>
<select class="dimension" name="Consultant">...</select>
<select class="dimension" name="Activity>...</select>
<input name="Rate" data-behavior="MatrixLookup" data-matrixlookup-options="{{'matrix': 'Consultant Rates', 'measure': 'Rate', 'dimensions': '.dimension'}}"/>
...
</form>
As a user changes the Consultant or Activity dropdown lists, the Rate text box will automatically be adjusted to the proper value.
Behavior Options- matrix (String, required): name of the Matrix
- measure (String, required): the output measure to use when setting the behavior element's value.
- dimensions (String, defaults to '.dimensions'): a css selector that determines which form elements are to be passed to the Matrix/Lookup method
- useSelectText (Boolean, defaults to true): if true, dropdown list dimensions will be based on the selected text, rather than the selected value
When the behavior is applied, each element returned by the options.dimensions css selector will have a change event handler added to it, causing a Matrix/Lookup AJAX call to be fired. The callback from this call sets the value of the behavior's element. |