Skip to Content
0

How to add a blank item after load the items from database?

Dec 13, 2016 at 07:36 AM

86

avatar image

Hi,

Actually, I have inserted the data into the "sap.m.Select" control from database.

But I need to add one more item at 0th index i.e. "--Select--". after getting the data from database. I have tried the below code for the same

var firstItem=new sap.ui.core.Item({ key: "--Select--", text: "--Select--" }); sap.ui.getCore().byId("countryInput").addEventDelegate({
"onAfterRendering": function () { sap.ui.getCore().byId("countryInput").insertItem(firstItem,0)

} }, this)

I have inserted this code in onint function in controller

But there are two things happened when I using the above code.

1. Multiple "--Select--" added

2. After adding the "--Select--" item when I tried to select it. It is not able to select.

Please suggest!

Thanks & Regards

Somdutt Sharma

10 |10000 characters needed characters left characters exceeded

Can you not insert that row in the backend odata service?

0
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Deepak Anumula Dec 13, 2016 at 02:42 PM
0

Hi Sharma,

Please use the sap.m.combobox instead of sap.m.select
Hope u can achieve what u r expecting...

If u have any doubt please reply back.

Thanks,

Deepak Raj.

Share
10 |10000 characters needed characters left characters exceeded
Jun Wu Dec 13, 2016 at 08:14 PM
0

just manipulate the model

let's say you bind the dropdown to array ddArray

ddArray.splice(0, 0,{ key: "--Select--", text: "--Select--" })

Share
10 |10000 characters needed characters left characters exceeded