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
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 7 | |
| 5 | |
| 4 | |
| 2 | |
| 2 | |
| 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.