Hi,
I have the following challenge:
I have a product selection page and a shopping basket page. The content of the shopping basket is in the session (storage) as an array. When I select a product on the selection page, it should be added to the shopping basket. The problem is that the shopping basket doesn't get updated, I don't see the products which I add.
When I click on the Add button on the selection page, I call a function which adds an item to my shopping basket array. So far so good.
On the shopping basket page I get the array and create a JSON from it. I set this JSON data to my model. Once I have a model, I bind it to a table. The binding works when I start up the application, but when I add additional products to the shopping basket, I don't see them on my shopping basket page.
The array is ok, I see the new items added.
The JSON is ok, I see the new items added.
The model is ok, I see the new items added.
Still, the binding is not updated.
In the product selection function:
jQuery.sap.storage.put("order_matnr", oArray_order_matnr);
I build my array. It looks like ["000000000000020104","000000000000020105","000000000000020104","000000000000020295"]
In the shopping basket view:
var mySelectedProductnames=jQuery.sap.storage.get("order_matnr");
var aData = new Array();
if (mySelectedProductnames!= null) {
var len = mySelectedProductnames.length;
for (var i = 0; i < len; i++) {
aData.push({
matnr: mySelectedProductnames[i],
});
};
};
var oModel_orderjson = new sap.ui.model.json.JSONModel();
oModel_orderjson.setData({modelData : aData});
console.log(oModel_orderjson); //my model looks good, updated after each additional product ordering
Then I use oTable_orderoverview_self.bindItems
and
oTable_orderoverview_self.setModel(oModel_orderjson);
It all works for products which are in the array (in the storage) when I reload the application. But when I add products during using the application, I manage to update the array, the JSON, the model, but not the table.
Any advice is appreciated!
Thanks,
Tamas