LookupField
Selects a record through suggestions or an F4 lookup dialog.
When to use
- Look up a related record by its code or descriptive name.
Examples
Lookup by code or name
Loading the example
<k:LookupField label="Warehouse" rows="{/sites}" keyPath="id" textPath="name" change=".onChange"/>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast"], (Controller, Toast) => Controller.extend("sample.LookupFieldChange", {
onChange(event) {
Toast.show(event.getParameter("text") || "Selection cleared");
}
}));Assign multiple warehouses
Open the search dialog and narrow the results by area.
Loading the example
<k:LookupField label="Assigned warehouses" rows="{/sites}" keyPath="id" textPath="name" infoPath="region" multiple="true" change=".onChange">
<k:columns>
<k:Column label="Code" path="id" width="100"/>
<k:Column label="Warehouse" path="name" grow="1"/>
<k:Column label="Area" path="region" grow="1"/>
</k:columns>
<k:filterFields><k:FilterField label="Area" path="region"/></k:filterFields>
</k:LookupField>sap.ui.define(["sap/ui/core/mvc/Controller", "kor/ui/Toast"], (Controller, Toast) => Controller.extend("sample.LookupFieldChange", {
onChange(event) {
const selection = event.getParameter("selection") || [];
Toast.show(selection.map((record) => record.text).join(", ") || "Selection cleared");
}
}));Keyboard
- F4
- Open the lookup dialog from the field.
API
Properties
| Name | Type | Default | Description |
|---|---|---|---|
value | string | Key of the selected record in single-selection mode | |
text | string | Display text of the selected record in single-selection mode | |
selection | object | null | Array of selected records as {key, text} in multiple-selection mode |
multiple | boolean | false | Whether multiple records can be chosen |
keyPath | string | id | Path to a record's key |
textPath | string | name | Path to a record's display text |
infoPath | string | Path to secondary text in suggestions | |
label | string | Field label and dialog title | |
placeholder | string | Placeholder | |
help | string | Supporting text | |
error | string | Validation message | |
required | boolean | false | Whether selection is required |
enabled | boolean | true | Whether the field can be used |
Aggregations
| Name | Type | Description |
|---|---|---|
columns | Column[] | Dialog columns. Defaults to key and text |
filterFields | FilterField[] | Available dialog filters |
rows | sap.ui.core.Element[] | Records supplied by a list binding without a template |
Events
| Name | Type | Description |
|---|---|---|
change | value: stringtext: stringcontext: objectselection: object | The selection changed |
Methods
| Name | Description |
|---|---|
getSelectedKeys(): string[] | Returns selected keys in multiple-selection mode for form validation |
type LookupEntry = { key: string; text: string };Column
A column in a DataGrid or TreeGrid.
Properties
| Name | Type | Default | Description |
|---|---|---|---|
label | string | Header | |
path | string | Field path relative to the row context | |
type | string | text | text, link, number, currency, date, status, progress, person or spark |
width | float | 140 | Width in pixels |
grow | float | 0 | Share of the available extra width |
decimals | int | 0 | Number of decimal places |
unitPath | string | Path to the unit or currency field | |
statePath | string | Path to a status field with success, wait, danger, info or none | |
states | object | Mapping from cell values to statuses | |
options | object | Choices offered when editing | |
editable | boolean | false | Whether cells can be edited |
sortable | boolean | true | Whether the column can be sorted |
pinned | boolean | false | Whether this leading column stays in place during horizontal scrolling |
formatter | function | Function that formats a value and row context as text |
FilterField
A field available in a FilterBar.
Properties
| Name | Type | Default | Description |
|---|---|---|---|
label | string | Field label | |
path | string | Model path | |
type | string | text | text, number or option |
options | object | Available choices | |
unit | string | Unit displayed with a numeric value |