Skip to Content

How to pass values from a client based model from one view to another using eventBus?

Hi All,

I am trying to pass a model from one controller to another.

Static data is getting passed using the event bus technique.

But when it comes to passing a model, then I am not able to get back any data.

Please give me the right syntax to pass a model in this context.

I tried almost everything.

This is the first master controller.capture1.png

This is the second detail controller capture2.png

capture1.png (29.8 kB)
capture2.png (37.0 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Mar 06, 2017 at 01:31 PM

    usually we don't that, model can be stored at component level, which can be accessed in any view directly.

    Add comment
    10|10000 characters needed characters exceeded

    • Thanks Jun.

      Yeah, that's right.

      But could you just suggest me some technique by which I could flow the client based json data from one controller to another.

      Thank you for the help. :)

      Regards,

      Aakanksha

  • avatar image
    Former Member
    Mar 06, 2017 at 11:19 AM

    Hi Aakanksha,

    Don't know if its exactly what you are looking for, but this is how i usually pass data from one controller to the other, maybe you can pass an odata object too.

    view.byId("idAppControl").to("FullScreen", "fade", {
    "pageToGetBack" : "DashBoard",
    "itemToShow" : table,
    "title" : _title
    });
    
    //and on the fullscreen controller i have this code
    onInit : function(evt) {
    
    		this.getView().addEventDelegate({
    			onBeforeShow : function(evts) {
                                    //inside evts.data will be all the parameters you passed
    				_that.pageToReturn = evts.data.pageToGetBack;
    				page.setTitle(evts.data.title);
    				}
    		});
    
    
    

    Best

    Leandro

    Add comment
    10|10000 characters needed characters exceeded

    • Thanks Leandro.

      I used this technique earlier, but there was a route based issue everytime.

      So I switched on the eventBus technique.

      Here, using this static data was flowing well, but the client based json file was not flowing based on the primary key.

      Thanks for the help. :)

      Regards,

      Aakanksha Gupta

  • avatar image
    Former Member
    Mar 06, 2017 at 09:40 PM

    Hi Akanksha,

    set the model to core in view1 and you can acess this in view2.

    sap.ui.getCore().setModel()

    Alternatively, set it at component level.

    Regards,

    Gowrinath

    Add comment
    10|10000 characters needed characters exceeded

    • Thanks Gowrinath.

      Actually, I am a beginner in this field of SAPUI5. I am trying to implement a master detail application.

      I wanted to select a field from the master view and display its details in the detail view.

      I am able to select the data and flow only static data from one master to detail controller.

      As a result of which I am updating the view accordingly.

      Thanks for the reply :)

      Regards,

      Aakanksha Gupta