cancel
Showing results for 
Search instead for 
Did you mean: 

How to get ComboBox's selected item to detail page?

Former Member
0 Kudos

Hi All,

I have created Master Detail demo app,in which I want to get comobox's item to detail page.I have done this thing with JSView but not able to do in XMLView.

Master View

<ComboBox id="combo1" selectionChange="test">

  

  </ComboBox>

Master Controller


test : function(){

alert(this.byId("combo1").getSelectedItem().getText());

}

I am getting Alert value with selected item.But if I write in detail page's controller as below I am not getting value.

onInit : function() {

alert(sap.ui.getCore().byId("combo1").getSelectedItem().getText());

}

Any clue to solve this problem??

Help would be appreciated.

Regards,

Zalak Dalal

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Zalak,

You have to function 'EventBus' for transfer data from MasterView to DetailView.

MasterViewController

sap.ui.getCore().getEventBus().publish("app", "GetComboText", {

        comboText : sap.ui.getCore().byId("combo1").getSelectedItem().getText()

      });

DetailViewController

onInit: function() {

      var bus = sap.ui.getCore().getEventBus();

      bus.subscribe("app", "GetComboText", this._showComboText, this);

    }

_showComboText : function(channelId, eventId, data){

    alert(data.comboText);

}

by sapui6.com

Former Member
0 Kudos

Hi Seungwon,

I am not getting alert box.

in masterview controller

comboText : sap.ui.getCore().byId("combo1").getSelectedItem().getText()

is not working instead of it i wrote comboText : this.byId("combo1").getSelectedItem().getText()

but still alert box is not coming.

former_member182862
Active Contributor
0 Kudos

HI Zalak

Can you do this in the onAfterRendering of the view?

-D

Former Member
0 Kudos

Thanx for reply Dennis.But it is not working.

former_member182862
Active Contributor
0 Kudos

I am pretty sure that the control id is not "combo1". Can you using chrome/firefox debugger to see the rendered HTML to cross check.

-D