| Posted by: WUICTeam - Thursday, November 5, 2026 9:01:56 AM |
|---|
| [b]Update:[/b] the documentation of [c]slimCombo[/c] together with a computed display formula has been corrected. Fixed in [url=https://wuic-framework.com/downloads/release-notes#v1.8.2]WUIC Framework 1.8.2[/url]. [i]The original answer below describes versions before 1.8.2.[/i] [b]Question[/b] I have a lookup on a product column and I want to fill the description, unit price and VAT code of the row when the user picks a product. Is there a way to read those values from the selected record without a second request to the server? The properties I need are not the lookup's value or text field, and they come back [c]undefined[/c]. [b]Answer[/b] Yes: list the extra columns in [c]mc_props_bag.slimCombo[/c] and read them from [c]<column>__lookup_obj[/c] inside [c]mc_selection_changed_custom_function__fn[/c]. By default the lookup dropdown runs a slim SELECT on the related table: the primary key, [c]mc_ui_lookup_dataValueField[/c] and [c]mc_ui_lookup_dataTextField[/c] only. That keeps the payload small, but it also means any other column of the product is simply not in the record you get on selection. [c]slimCombo[/c] is an array of extra column names added to that SELECT: [code] { "slimCombo": ["unita_misura_id", "codice_iva_id", "prezzo_vendita"] } [/code] Then, in the selection-changed callback, the selected related record is available as [c]record['<column>__lookup_obj'].value[/c]: [code] prodCol.mc_selection_changed_custom_function__fn = (record, _f, _m, newValue) => { const prod = record['prodotto_id__lookup_obj']?.value; if (!prod) return; record['prezzo_unitario']?.next(prod.prezzo_vendita); record['codice_iva_id']?.next(prod.codice_iva_id); }; [/code] [b]Things to watch[/b] [list] [*][c]slimCombo[/c] lives at the top level of [c]mc_props_bag[/c], not under [c]lookup[/c]. Placed under [c]lookup[/c] it is silently ignored. [*]If the property is [c]undefined[/c], first check that the column name is spelled in [c]slimCombo[/c] exactly as in the related table. [*][c]slimCombo: false[/c] turns the restriction off and the combo returns every column: handy for debugging, heavier on the wire. [*]If the column uses [c]mc_ui_lookup_combo_text_edit_computed_dataTextField[/c] and no [c]slimCombo[/c] array, the combo returns all columns because the formula may reference any of them. [/list] The trade-off is a slightly larger combo response, in exchange for no extra by-id request on every selection. [url=https://wuic-framework.com/docs/field-widget-lookup]Documentation: Widget Lookup[/url] |