F4 Value Help in OpenUI5 Without sap.ui.comp

sap.ui.comp.valuehelpdialog.ValueHelpDialog is part of SAPUI5 and is not shipped with OpenUI5. In OpenUI5 you can open a sap.m.TableSelectDialog from the valueHelpRequest event of sap.m.Input. F4 triggers that event from the keyboard.
Value help with TableSelectDialog
<Input id="plant" value="{/plant}" showValueHelp="true" valueHelpRequest=".onValueHelp"/>
<TableSelectDialog id="dialog" title="Plants" items="{/plants}" search=".onSearch" confirm=".onConfirm">
<columns>
<Column><Text text="Plant"/></Column>
<Column><Text text="Name"/></Column>
</columns>
<items>
<ColumnListItem>
<Text text="{id}"/>
<Text text="{name}"/>
</ColumnListItem>
</items>
</TableSelectDialog>
onValueHelp: function () {
this.byId("dialog").getBinding("items").filter([]);
this.byId("dialog").open();
},
onSearch: function (event) {
event.getSource().getBinding("items").filter(
new Filter("name", FilterOperator.Contains, event.getParameter("value")));
},
onConfirm: function (event) {
const item = event.getParameter("selectedItem");
if (item) {
this.getView().getModel().setProperty("/plant", item.getBindingContext().getProperty("id"));
}
}
Load Filter and FilterOperator from sap/ui/model. search runs when the user starts the search. The handler for valueHelpRequest removes the old filter, so the dialog always opens with the full list.
Focus the field, press F4 and choose Lyon. Result: /plant contains 2000.
Two common mistakes
- The user types an invalid key. The dialog does not check typed text. Validate in the
changeevent or setvalueHelpOnly="true". - The list is large. A client filter only sees loaded data. With OData, the filter on the binding is sent to the service; keep
growingenabled.
Suggestions, columns and filters in one field
Kor, our open-source UI5 library, has a LookupField. It suggests while the user types and opens a table with filter fields on F4:
<LookupField label="Plant" value="{/plant}" rows="{/plants}"
keyPath="id" textPath="name" infoPath="country" change=".onChange">
<columns>
<Column label="Plant" path="id" width="110"/>
<Column label="Name" path="name" grow="1"/>
<Column label="Country" path="country" width="110"/>
</columns>
<filterFields>
<FilterField label="Name" path="name"/>
<FilterField label="Country" path="country"/>
</filterFields>
</LookupField>
In the dialog, double-click a row or press Enter to choose it. No controller code is needed for that. value receives the key and change also returns the text and the binding context.
Which one to use
| Requirement | TableSelectDialog |
Kor LookupField |
|---|---|---|
| Ships with OpenUI5 | Yes | No, npm package |
| One search field | Yes | Yes |
| A filter per column | Write it yourself | filterFields |
| Include and exclude ranges | No | No |
| Standard Fiori look | Yes | No |
If you have a SAPUI5 license and need select-option ranges, ValueHelpDialog remains the closest match.
We ran both examples in Chrome with OpenUI5 1.108.55 and 1.154.0, using a JSON model.
Sources: sap.m.TableSelectDialog API · sap.m.Input API · OpenUI5 1.108.55 library list