cancel
Showing results for 
Search instead for 
Did you mean: 

Make Cursor appear on an editable field in Object Page Table

philipdavy
Contributor
0 Kudos

Hello Experts,

I am developing a scanning application app and my requirement is that after successfull scan of a product , the cursor should appear on the particular field of the table row . How to achieve the same ? I have developed the app with list report - Object page fiori elements template.

I already have the reference of the table row and here I get the values of each fields in a row .

var oProperty = this.getView().getModel().getProperty(oTable.getItems()[i].getBindingContext().getPath());

How can i set the cursor to a particular field ?

View Entire Topic
nicoschoenteich
Developer Advocate
Developer Advocate

Hi there,

I believe you need a way of accessing the specific input field - maybe open the console and see if there is something unique about that field, or maybe it's always(?) the n-th child of the row or something like that. Once you have the input field reference you can fire a press event on that input field ( .firePress() ), which puts the cursor into the field.

Best, Nico

philipdavy
Contributor
0 Kudos

nicolai.geburek

Thanks for your answer. This looks promising. The uniquiness about this field would be the id itself. But the id is dynamic in nature.

Is there any way to get the ID of the input field ?

nicoschoenteich
Developer Advocate
Developer Advocate
0 Kudos

How about looping through all children of the table row and finding the first one that is of type sap.ui.comp.smartfield.SmartField ?

philipdavy
Contributor
0 Kudos

nicolai.geburek

Can you please give me a hint on the method which has to be used to find the field(or ID of a field) with type of ui5 control ?

nicoschoenteich
Developer Advocate
Developer Advocate
0 Kudos

If you call getMetadata() on any control you should get the control type.

philipdavy
Contributor
0 Kudos

nicolai.geburek

I am doing like this as you mentioned , but the line with firePress() is throwing error . Am i doing anything wrong here ?

for ( var i = 0; i < cells.length; i++ ) { var cell = cells[8]; var cellID = cell.getId(); sap.ui.comp.smartfield.SmartField.byId(cellID).firePress(); }
nicoschoenteich
Developer Advocate
Developer Advocate
0 Kudos

Do something like this for the cell inside a table row:

for (let i = 0; i < cells.length; i++) {
  const cell = cells[i];
  if (cell.getMetadata().getName() === "sap.ui.comp.smartfield.SmartField") {
    cell.firePress();
  }