cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 error showing data in Detail View

MariusStoica
Active Participant
0 Kudos

Hi guys,

I seem to have a trouble with Master/Detail shell of a Fiori app.

Although I followed the "guidelines" to pass the data to the Detail view (I actually gave a name to the model of the Master view, "Master"):


handleListSelect : function (evt) {

  context = evt.getParameter("listItem").getBindingContext("Master");

  this.nav.to("Detail", context);

  },

In console I see the model and path of the selected item:


evt.getParameter("listItem").getBindingContext("Master");

constructor {oModel: F, sPath: "/0"}

On the Detail view, I don't see the data.


<ObjectHeader>

  <attributes>

     <ObjectAttribute text="Nr. comanda: {OrderNo}"

         state="{path: 'OrderStatus',

            formatter: 'sap.ui.demo.myFiori.util.Formatter.statusState'

            }"/>

     <ObjectAttribute text="Material: {Material}" />

  </attributes>

And the model data is something like:

I even tried all the paths I could think of (there is no model applied to the Detail view):


<ObjectAttribute text="{Material}" /> //Contextual path

<ObjectAttribute text="{/Material}" /> //Root path

<ObjectAttribute text="{0/Material}" />

<ObjectAttribute text="{/0/Material}" /> //Exact path or something like that since I know the position - tried it 😛

Conclusion: The fields simply do not exist in the view.

Do you guys see a reason why ?

Regards,

Marius

PS:Using http://go.sap.com/documents/2015/08/82cfd7b7-5b7c-0010-82c7-eda71af511fa.html and SAPUI5 SDK - Demo Kit as references.

     As of "SAPUI5 SDK - Demo Kit", if I want to access the data from my binding, I use "/entity" (as in my case), right ? Am I understanding it wrong ?

View Entire Topic
Caspar_van_t
Explorer
0 Kudos

Hi Marius,

I am not quite sure what you mean with this code:

  1. constructor {oModel: F, sPath: "/0"

Could you share a little more of your code?

Depending on how the model is set to your view, can you try this code:

  1. constructor {oModel: F, sPath: "Master>/0"}

AND


  1. <ObjectHeader> 
  2.   <attributes> 
  3.      <ObjectAttribute text="Nr. comanda: {Master>OrderNo}" 
  4.          state="{path: 'Master>OrderStatus', 
  5.             formatter: 'sap.ui.demo.myFiori.util.Formatter.statusState' 
  6.             }"/> 
  7.      <ObjectAttribute text="Material: {Master>Material}" /> 
  8.   </attributes> 

Let me know if this works, and if it does not work, could you give some more code?

Cheers,

Caspar

MariusStoica
Active Participant
0 Kudos

Hi Caspar,

As I said in the original post, the view Detail does not have a model attached to it, and by what I understand from the line of code:


context = evt.getParameter("listItem").getBindingContext("Master");

it only attaches the data (i.e. Model and path), not the entire Model "Master" of the Master view.

Whereas

  1. constructor {oModel: F, sPath: "/0"}"

was just the console response to the code


context = evt.getParameter("listItem").getBindingContext("Master")

Nor "


sap.ui.getCore().byId("Detail").getModel()

" neither "


sap.ui.getCore().byId("Detail").getModel("Master")

" give me the data. Only "


sap.ui.getCore().byId("Detail").getBindingContext()

" shows me the exact same context that Master passed to it.

Caspar_van_t
Explorer
0 Kudos

Okay, and if you paste in this code, does that work?

  1. <ObjectHeader>
  2.   <attributes>
  3.      <ObjectAttribute text="Nr. comanda: {Master>OrderNo}"
  4.          state="{path: 'Master>OrderStatus',
  5.             formatter: 'sap.ui.demo.myFiori.util.Formatter.statusState'
  6.             }"/>
  7.      <ObjectAttribute text="Material: {Master>Material}" />
  8.   </attributes>

MariusStoica
Active Participant
0 Kudos

Nope, probably because the "Master" model is not attached to the view, correct?

PS: The code I'm using is from Building SAP Fiori-like UIs with SAPUI5 in 10 Exercises

Caspar_van_t
Explorer
0 Kudos

Hi Marius,

Your items do indeed need a model to bind on.

Is your model set to your view?

If you want to go from master to detail, its best to bind relatively.

So for example;

1: Bind the model to both views

2: When the Master item is pressed, set the detail binding path to the item pressed

3: Bind your items relatively by NOT using the "/" in front of your bindings

For more information on doing this, try checking out the master-detail template thats used in the SAPWebIDE, or check out this link:

OpenUI5 SDK - Demo Kit

For now, what happens when you bind your Master model to your sap.ui.getCore() and/or your detail view?

That will probably fix the issue

(remember that if you "name" your model, ALWAYS use this name in your bindings)

Cheers,

Caspar

MariusStoica
Active Participant
0 Kudos

Tried it, doesn't work.

There is one big difference between the examples and my JSON model.

That is : The example JSON model has the "SalesOrderCollection" object


{

  "SalesOrderCollection": [

  {

  "OrderNo": "300000097",

  "Material": "Material1",

  "TargetQ": "13224.00",

  "DelivQ": "11113.00",

  "UM": "BUC",

  "SchedStartTime" : "2013-05-20T22:00:00",

  "SchedEndTime" : "2013-05-25T22:00:00",

  "ActStartTime" : "2013-05-21T22:00:00",

  "OrderStatus": "S",

  "CompAvail1" : "Y",

  "CompAvail2" : "1234"

  },

Whereas my JSON has only the data:


[{"Material":"B94529000BREP","OrderNo":"000100765931","ItemNo":"0001","TargetQ":"10.000","DelivQ":"0.000","UM":"ST","Status":"","SchedStartTime":"2016-08-30 14:27:00","SchedFinishTime":"2016-08-30 14:23:07","ActualStartTime":"2016-08-31 16:34:17","CompAvail1":"","CompAvail2":""},{"Material":"B94529000BREP","OrderNo":"000100765933","ItemNo":"0001","TargetQ":"500.000","DelivQ":"0.000","UM":"ST","Status":"","SchedStartTime":"2016-09-12 24:00:00","SchedFinishTime":"2016-09-12 20:45:20","ActualStartTime":"2016-09-09 09:47:27","CompAvail1":"","CompAvail2":""}]

Because of this, when the example attaches the model to the "app" (not the view Master or Detail, but to the app) it can be accessed bu it's data name (i.e. "SalesOrderCollection")


<List

  id="list"

  mode="{device>/listMode}"

  select="handleListSelect"

  items="{/SalesOrderCollection}" > //Examle from MyFiori10

I tried using


items="{/}"

to my Master list, in order to fetch the 2 items of the global model, but it didn't work