on 09-09-2016 1:35 PM
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 ?
Hi Marius,
I am not quite sure what you mean with this code:
Could you share a little more of your code?
Depending on how the model is set to your view, can you try this code:
AND
Let me know if this works, and if it does not work, could you give some more code?
Cheers,
Caspar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
Okay, and if you paste in this code, does that work?
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
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:
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
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
User | Count |
---|---|
72 | |
9 | |
8 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.