on ‎2015 Oct 02 7:26 AM
Hi,
I have a problem and need your help in solving the same. I am a newbie in SAPUI5
I am creating a Master/Detail SAP UI5 application which displays list of Articles on left Master page and Variants on Detail page. The implementation is similar to EPM_OIA_BPOENINV example, SAP provided in 740, creating object of Shell to hold both Master and Detail XML views.
I created two entity sets, ARTICLEINFOSET and VARIANTINFOSET and maintained navigation between them. It's working perfectly fine, with 2 Odata services including BATCH operations to save the data.
The Model is set to SAP.UI.GETCORE() by passing url to Model object:
var url = model.Config.getServiceUrl();
m = new sap.ui.model.odata.ODataModel(url, true);
sap.ui.getCore().setModel(m);
So all Odata requests are now binded to this level.
In the Master view, I defined sap.m.List with "items" attribute pointing to "{path : '/ARTICLEINFOSET'}". This calls OData service and fetches the Articles and binds to the List.
In Detail view, I defined sap.m.Table with with "items" attribute pointing to "{path : '/VARIANTINFOSET'}". This calls OData service and fetches the Variants, for the corresponding Article selected in the left navigation and binds to the List.
Now, the problem, I have a custom button declared in Detail Footer section which on clicking, gives a Mass Update pop-up, which on entering a value, the corresponding data should be updated back to Sales Order Item Quantity field in all rows. And here I am stuck. I am not getting clue on how to update data which is bound to the table.
As mentioned, all my data getting displayed in the view is present in Model, which is bound at application level.I don't have explicit Table declarations in javascript.
Model's Default Binding Mode is "OneWay". "TwoWay" is not working.It's only updating first row and then binding for next rows, it's showing getAggregation is NULL. So I need to do this change only by "OneWay".
Request you all to guide me in solving this issue.
Request clarification before answering.
With the UI5 odata V2 model, you can do it quite simple. You can try something as below on mass update,
//store all the context/contextPath of the table in an array
var aContexts = oTable.getItems().map(function(oItem){
return oItem.getBindingContext().getPath(); // binding path
});
//iterate over the context array and change values in the model
aContexts.forEach(function(sPath){
model.setProperty(sPath+'/<property-to-be-updated>',"<value>");
});
//submit all the changes to the backend.
model.submitChanges();
You can find a simple example - JS Bin - Collaborative JavaScript Debugging
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Thanks a ton Maksim and Sakthivel.. It's working flawlessly now with V2 Odata Model
But I have one more problem. In SAVE method, when i am calling submitChanges(), it's not displaying any alerts:
this.getView().getModel().submitChanges(function() {
this.getView().getModel().refresh();
alert("Update successful");
},
function() {
alert("Update failed");
}
);
Any reason why no pop-up is getting displayed ? Or How can I display the pop-up on successful SAVE ?
Thanks again
As of now I have screen as displayed below. Search button is on top of Master Page. Master/Detail pages are part of Split-App, default view.
Now I need to create a new simple Search view, which will be first displayed and then on 'Search', it should navigate to Split-App view and back and forth.
Shall I create new thread for this ?
Thanks,
Harish
is using v2 ODataModel an option?
If not, the only way IMHO is to copy values to JsonModel and copy back when submitting
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
switch to
set two way binding, and when you wanna submit changes to server just call submitChanges
Did the same. Changed to v2 model. and set TwoWay binding. But I want to know how to update the changes from the pop up value to Odata model's table items.
With V2 Odata model as well, I am able to SAVE the changes by using submitChanges(). But still not able to change the UI table column values. Here is the code for Mass Update functionality. With TwoWay, it's updating first row and then displaying getAggregation is NULL:
It's updating Model.OData bindings but not the table aggregations
Any info on how to update the aggregations.
When I try to update using the below code, it's updating first record and then saying, getAggregation is NULL for second iteration:
aItems[i].getAggregation("cells")[3].setProperty("value", newtgtstk);
To do the UI changes to the table, I used oTable.getModel().updateBindings(); and now the UI is updated with new values, as I am doing changes to the Odata data in the Model.
But with this, now Model.submitChanges stopped working, as I think, Bindings had been updated with above statement and Model is not able to recognize any changes done.
So I switched back to V1 Odata Model and started using "createBatchOperation" and "submitBatch" to manually tell Model to update the changes even after bindings were updated.
Any info to proceed further on this ??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 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.