Search code examples
sapui5

SAPUI5 - navigation - Binding not working


Demo - http://jsbin.com/bukanagobu/1/edit

The problem is when i click on one of the item, it navigates to the next view but it is not displaying the firstname and lastname.

I have saved the model as 'data'.

Can anyone help me in finding the error ?


Solution

  • You have made two mistakes in your code:

    • When getting the binding context upon clicking an entry in the list, you must specify the named model name 'data':

      var oBindingContext = evt.getSource().getBindingContext("data"); 
      // if using named models, specify which model you want to use 
      
    • Also, when setting the binding context to the detail view, you must also set the model name to 'data':

      page2.setBindingContext(oBindingContext, "data"); 
      // also, name the context model to 'data' 
      

    See the updated JSBin here : http://jsbin.com/fehoqu/1/edit?html,output