Skip to Content
0

SAPUI5 - read token from input field

Jan 30, 2017 at 02:39 PM

217

avatar image

Hi,

I am using a Value Help Dialog for one input field. I get the data selected and a "token" is returned to my input field. Now I am trying to read the value of the input field (which contains the token) like this but it does not get the value. When I write something into the input field without using the value help, I get the value.

How can I get the value from the token?

Thanks,

Tim

this.getView().byId("SoldToInput").getValue();
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Jun Wu Jan 31, 2017 at 03:50 PM
0
this.getView().byId("SoldToInput").getTokens()
Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Jan 30, 2017 at 02:52 PM
0

your code.....

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Here is the code to set the token to the input field after selecting the row in the value help:

oInit:

this.theTokenInput= this.getView().byId("SoldToInput");
this.aKeys=["CustomerCode"];
ok:function(oControlEvent){//that.aTokens = oControlEvent.getParameter("tokens");//that.theTokenInput.setTokens(that.aTokens);

var oCore =sap.ui.getCore();
    var oSoldToInput = oCore.byId("SoldToInput");
    var oHelpTable = oValueHelpDialog.getTable();
    var oContext = oHelpTable.getContextByIndex(oHelpTable.getSelectedIndex());if(oContext){
            var oSel = oContext.getModel().getProperty(oContext.getPath());
    var token1=newsap.m.Token({key: oSel.Customer,text: oSel.Name});
    var oSoldToInput = oSel.Customer;
    that.aTokens=[token1];
    that.theTokenInput.setTokens(that.aTokens);

xml:

json.soldTo   = this.getView().byId("SoldToInput").getValue();

Thanks,

Tim

0

did u debug?

0

Yes, it returns the value as blank, no error.

json = Object{soldTo: ""}

0
Jun Wu Jan 31, 2017 at 02:34 PM
0

debug this portion

var oCore =sap.ui.getCore();
    var oSoldToInput = oCore.byId("SoldToInput");
    var oHelpTable = oValueHelpDialog.getTable();
    var oContext = oHelpTable.getContextByIndex(oHelpTable.getSelectedIndex());if(oContext){
            var oSel = oContext.getModel().getProperty(oContext.getPath());
    var token1=newsap.m.Token({key: oSel.Customer,text: oSel.Name});
    var oSoldToInput = oSel.Customer;
    that.aTokens=[token1];
    that.theTokenInput.setTokens(that.aTokens);
Show 1 Share
10 |10000 characters needed characters left characters exceeded

it gets the value from the value help selected line and puts it to theTokenInput and it is then visible in the input field:

and it is then visible in the input field:

But how can I then get the value again from the input field? Do I need to read the token again?

At least with this, I don't get the value:

this.getView().byId("SoldToInput").getValue();
debug.png (35.2 kB)
debug2.png (2.2 kB)
0