THI
THI

Reputation: 365

Focus on Input Field Within Dialog

I have an input field along with two other controls in a dialog box. How to ensure that the moment the dialog box opens, the cursor is on the input field (id="P1")?

XML View

<Dialog id="ABC">
  <!-- ... -->
  <Input id="P1" value="{order>/OrderNo}" />
  <!-- ... -->
</Dialog>

Upvotes: 0

Views: 1846

Answers (1)

Erch
Erch

Reputation: 625

There is a association in the dialog control called

initialFocus

https://sapui5.hana.ondemand.com/1.54.8/#/api/sap.m.Dialog/associations

In case you don't know about associations:

It is a basic relation between two controls. In the 1 to 1 relation that is needed in your example the id of the "lesser" control is stored in the "higher". (not shure how to descripe that the right way)

In following example the label and its input field are associated that way. The "lesser" controls id (input) is stored in the label that represents it:

https://sapui5.hana.ondemand.com/1.54.8/#/sample/sap.m.sample.Label/code

SAPs explanation:

https://sapui5.hana.ondemand.com/1.54.8/#/topic/5ee3be4727864bb08b991414e0428e38

In your exaple the xml would look smth like:

<Dialog id="ABC" initialFocus="P1"..... >
.
.
.
    <Input id="P1" ... />
.
.
.

Upvotes: 2

Related Questions