on 01-13-2015 6:16 AM
Hi Experts
I run the code I paste at the end of the Discussion with no problem, but if I want to display only one result
Instead of path: "/Orders",
I want to use path: "/Orders(10251)",
This error appears
Query options $orderby, $inlinecount, $skip and $top cannot be applied to the requested resource
If I run the call on the browser, and there is no problem.
http://services.odata.org/Northwind/Northwind.svc/Orders(10251)?$expand=Customer
Is there any work around to display only one result also using the $expand
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m,sap.ui.table"
data-sap-ui-theme="sap_bluecrystal">
</script>
<!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->
<script>
var url = "proxy/http/services.odata.org/Northwind/Northwind.svc/";
var oModel = new sap.ui.model.odata.ODataModel(url, true);
sap.ui.getCore().setModel(oModel);
var oTable = new sap.ui.table.Table("table", { // create Table UI
title: "Northwind - Orders",
columns : [
{label: "ID", template: "OrderID" },
{label: "Date", template: "OrderDate" },
{label: "Contact Name", template: "Customer/ContactName"}
]
});
oTable.bindRows({
path: "/Orders",
// path: "/Orders(10251)",
parameters: {
expand:"Customer"
}
}); // bind the table rows
oTable.placeAt("content"); // place Table onto UI
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Regards
Henry
Hello Henry,
the binding path in that case must be a binding path to a list.
You can restrict the binding by defining a filter:
var aFilters = [];
var oFilter = new sap.ui.model.Filter("OrderID", sap.ui.model.FilterOperator.EQ, "10251");
aFilters.push(oFilter);
The filter array (aFilter) then an be used in the binding (https://sapui5.netweaver.ondemand.com/sdk/#docs/api/symbols/sap.ui.table.Table.html#bindRows).
Best Regards,
Florian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Florian for the quick replay.
Last Question
The previous test was made based on a particular situation. Now based on your reply,
I would like to know your opinion or recommendation, I have this Odata service
http://test.com:8000/ZSERVICE/DETAILSCollection(GUID='00155D0164001ED4A5B6FDBF8632959B',LANGUAGE='EN...
If I run the odata without the (GUID='00155D0164001ED4A5B6FDBF8632959B',LANGUAGE='EN')? no data is displayed... This is because the Odata service was designed this way. Should I talk to the Odata developer to allow the display of all Messages for the DETAILSCollection? I think this could be a wrong approach if you are using this Collection for displaying detail info only.
Regards and thanks again.
Henry
Hello Henry,
it depends on your requirements
In your service just the read method (GET_ENTITY) was implemented, but not the query method (GET_ENTITYSET). If you have the requirement to display all "details" in e.g. a table than you could implement the method.
Another point to consider is if the "details" entity is maybe related to a principal entity (e.g. SalesOrderItems are related to the principle entity SalesOrder). In such a case it would make sense to restrict the access to the depending entity via an association/navigation attribute between the principal entity and the depending entity (the restriction is done in the query method for the depending entity). This would result in following assuming we have a navigation attribute ToItems for the navigation from the principal entity to the depending entry (and the restrictions in the query method):
- .../SalesOrderItems -> not allowed
- .../SalesOrder('1000')/ToItems -> allowed
But as written above, it depends on your requirements.
Best Regards,
Florian
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.