on ‎2020 Aug 13 2:03 PM
Hi!
I implemented that you get the ID of the selected line (responive table) with one click and send them to another view.
With the help from mio.fujita
https://answers.sap.com/questions/13111243/smart-table-press-on-column-and-change-view.html#
onItemPress: function (oEvent) {
var id = oEvent.getSource().getBindingContext().getProperty("ProductID");
this.getOwnerComponent().getRouter().navTo("Detail", {
id: id
});
}
How do I get all entries that exist (of each line with this ID) with the read ID?
For example, I now have the ProductID from an order. How do I get the ordered goods or the quantity that is in a row with the read out ProductID?
Request clarification before answering.
Hi truckla,
For example, you can get data using OData model's read operation.
var oModel = this.getView().getModel();
var oFilter = new Filter({
path: "orderID",
operator: sap.ui.model.FilterOperator.EQ,
value1: "4"
});
oModel.read("/Orders", {
filters: [oFilter],
success: function (oRes) {
//here you can get data
}
});*If orderId is the unique key of your entity, you can just do this way:
oModel.read("/Orders('4')", {
success: function (oRes) {
//here you can get data
}
});
oRes will be a JSON array like below.

Regards,
Mio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi mio.fujita and thank you very much!
I don't understand where can I get my right value that is in your example "Orders" ? Where can I read it out from?
And where should I insert the code, in the onInit ?
If I try the root with "/" it doesn't work. I don't know where can I find the oModel.read("/Orders...
oModel2.read("/", {
success: function (oRes) {
//here you can get data
}
});
Hi Rick,
Let me clarify your requirement.
Your second view already shows the list of data which belong to order 4, and you want to send this data for further processing.
What is the trigger for sending the data? (button press, just after navigating to the second view...)
The path you specify in read request ( in below example, "/Orders" ) will be the entityset which is bound to the smartTable in the first view.
oModel.read("/Orders",https://sapui5.hana.ondemand.com/#/api/sap.ui.model.odata.v2.ODataModel%23methods/read
Hi Rick,
Great that the read request is now working!
Is your OData developed in SEGW project or from CDS?
In the case of SEGW, you need to implement filter operation in DPC_EXT class.
Also, make sure that "Filterable" attribute is checked in Entity definition.
You can for example use array's reduce function.
I'm assuming that you want to get values in below format.
>In the form order ID = 4; product IDs = 1,2,3,4; names= A,B,C,H; quantity= 1,1,2,56
var initalObj = { ProductId: [], ProductName: [] };
var oResult = oRes.results.reduce(function(acc, current) {
acc.ProductId.push(current.ProductID);
acc.ProductName.push(current.ProductName);
return acc;
}, initalObj);
console.log(oResult);
Here is what you'll get as oResult.

And the blow code will return the values concatenated by comma.

If you only want unique values, then you need to implement some check before pushing values into array.
//check if the same value already exists in the array
acc.ProductId.push(current.ProductID);
acc.ProductName.push(current.ProductName);
Hi mio.fujita,
maybe the example will make it clearer:

I have sent order ID 4 from the first view to the second view (already solved with your help).
Now the new view shows everything that exists for order ID 4:

Now I want to pass on this data or further process.
Everything about order ID 4.
In the form order ID = 4; product IDs = 1,2,3,4; names= A,B,C,H; quantity= 1,1,2,56
How do I do that?
How do I get the data?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.