Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Dec 13, 2016 at 02:42 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 13, 2016 at 08:14 PM

    just manipulate the model

    let's say you bind the dropdown to array ddArray

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

    Add comment
    10|10000 characters needed characters exceeded