cancel
Showing results for 
Search instead for 
Did you mean: 

How to set array as tokens to multi input control?

Former Member

Hi Experts,

I have an array where i am trying to set the array values as tokens to the multiinput control but could nt. The code i am trying with is in https://plnkr.co/edit/SJWN9qZwE2uSFZiqJIQ8?p=preview

Any suggestions to add the values in array as tokens to multi input control

Accepted Solutions (0)

Answers (3)

Answers (3)

Hello,

If you would like to avoid setting tokens by model, you can manually add them this way:

for(let i = 0; i < data.RESULT.length; i++){
    // For each result create new token and append it to the MultiInput field.
    // Token instance
         var defToken = new sap.m.Token({
             text: data.RESULT[i]
         });
    // Add created token to the Plant field
	 yourMultiInputField.addToken(defToken);
    }
rami_reddy4
Participant
0 Kudos

Hi Oskar Pietrucha,

I have implemented the same for loop of my application to insert the MultiInput data, Its working fine.

Thanks.

omkar_patil5
Discoverer
Better way it to create array of objects for adding multiple tokens to MultiInput Field

var MultiInput = sap.ui.getCore().byId("<Place id of your multiinput field");

var otoken1 = new sap.m.Token({
key: "001",
text: 'SAP'
});

var otoken2 = new sap.m.Token({
key: "002",
text: 'CLIENT'
});

this.aTokens = [otoken1, otoken2];
MultiInput.setTokens(this.aTokens);

Hi Michael

Hope this helps you : https://plnkr.co/edit/hbKhBWYrYCVt3qD6q0J7?p=preview

Regards

Shubhang

Former Member
0 Kudos

can the same be written in jsview?

new sap.m.MultiInput({ tokens:{text}{key}});
0 Kudos

Hi Michael

Yes it can be. Just follow the same structure.

Hope this answer was helpful to you. 🙂

Regards

Shubhang