cancel
Showing results for 
Search instead for 
Did you mean: 

Issue in Tokens while applying it to MultiInput

former_member190063
Participant
0 Kudos

Hi.

I have Multi Input where I am applying tokens to the control. So tokens have key and text properties. Previously I used key as integer and text as user input. The MutiInput tokens can change based user selection. I am storing tokens in model and applying it when user navigates to the same multiinput. Here the duplicate id error occuring. I replaced key value as User text value. But still I am getting the duplicate error. Have anyone came across this situation?

Code:

var sFrenchToken = mId.getTokens();

var getKey = sFrenchToken.getProperty("key");

var getTxt = sFrenchToken.getProperty("text");

var arr = [];

arr.push({ text: getTxt, key: getTxt});

var oModelEn = new sap.ui.model.json.JSONModel(arr);

<MultiInput id="mId" tokens="{oModelEn>/}">

<tokens> <Token key="{oModelEn>key}" text="{oModelEn>text}"/> </tokens> </MultiInput>

Error : adding element with duplicate id '__token0-__xmlview3--"id of my control"-0'

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member192494
Participant
0 Kudos

Hi Karthik,

I would suggest you to do the way as Yogesh said.

Though i didn't get id error, i could see the code broke at the second line.

You may replace with,

var getKey = sFrenchToken[0].getProperty("key");

var getTxt = sFrenchToken[0].getProperty("text");

Regards,

Ravikiran

yogesh_beria
Explorer
0 Kudos

Hi,

Looks like you are trying to get the tokens from the control, take the data from them, and then bind the data to the same control again.

Why not use only one approach? Either bind and get the data from the model or use the control methods to get / add tokens.