Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9008

How to set auto-select first item for sap.m.combobox?

$
0
0

Hi Experts,

 

I am using sap.m.combobox to bind some data. The data binding is done through Odata. Now the problem is how to get the first item automatically selected for that combobox when we run the app?

 

View : XML View

Code:

<ComboBox id="instance" selectionChange="pieData">

  

  </ComboBox>

 

Odata binding in onBeforeShow() - because this is the second page (navigation)

Code:

 

var oItemSelectTemplate1 = new sap.ui.core.Item({ 

    key : "{A20SMD_SINA}",     

    text : "{A20SMD_SINA}" 

         });

    sap.ui.getCore().byId('idPage2--instance').bindItems("Odata string",oItemSelectTemplate1);

 

I have tried the following code but it is not working. It is working only when I write the above data binding code in onInit(), but I cannot do that because this page which contains this combobox is the navigation page no 2 and odata also contains some parameters which are coming from the first page. So I have to bind the code in onBeforeShow() or onAfterShow().

 

firstitem1=sap.ui.getCore().byId('idPage2--instance').getFirstItem();

sap.ui.getCore().byId('idPage2--instance').setSelectedItem(firstitem1);

 

Please help me to resolve this issue. If you need any more information, please let me know.

 

Regards,

Niket Talati


Viewing all articles
Browse latest Browse all 9008

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>