Hello experts,
I am facing a new challenge "rebind a list with updated data from BackEnd". I have a list report & object page (OP).
In my OP. I added a custom action link to a Function Import. This function call backend and get updated data.
Here my problem, how refresh/rebind to my LineItem the new data ??
Version 1.38
Here my annotation file

Some code below
OnActionItemsRefresh: function(oEvent) {
var oBindingContext = oEvent.getSource().getBindingContext();
var sObjectPageData = oBindingContext.getModel().getProperty(oBindingContext.getPath());
var vFunctionName = "/ActionItemsRefresh";
var mParameters = {
"INVOICE": sObjectPageData.Invoiceid,
"FISCALYEAR": sObjectPageData.Fiscalyearid
};
// var oData = this.extensionAPI.invokeActions(vFunctionName,this.extensionAPI.getSelectedContexts(),mParameters);
var that = this;
try {
oBindingContext.getModel().callFunction(vFunctionName, {
method: "GET",
urlParameters: mParameters,
success: function(oData, response) {
// console.log(oData.results);
that.extensionAPI.rebind("InvoiceItems");
},
error: function(oError) {
// console.log(oError);
}
});
} catch (ex) {
// console.log(ex);
}
}
If you have any advice or answer ?
Thank you very much !!
Request clarification before answering.
Finally, with Cristian help, I did it. Below my code for help others.
OnActionItemsRefresh: function(oEvent) {
// Some var to get Id of LineItems, binding and key of entity
var vTableId = oEvent.getSource().getParent().getParent().getId();
var oBindingContext = oEvent.getSource().getBindingContext();
var sObjectPageData = oBindingContext.getModel().getProperty(oBindingContext.getPath());
// Create a filter to apply ActionRefresh
var aFilters = [];
var oFilter = new sap.ui.model.Filter("Invoiceid", sap.ui.model.FilterOperator.EQ, sObjectPageData.Invoiceid);
aFilters.push(oFilter);
oFilter = new sap.ui.model.Filter("Fiscalyearid", sap.ui.model.FilterOperator.EQ, sObjectPageData.Fiscalyearid);
aFilters.push(oFilter);
oFilter = new sap.ui.model.Filter("Actionrefresh", sap.ui.model.FilterOperator.EQ, "'X'");
aFilters.push(oFilter);
// Apply filter and let backend works !
this.byId(vTableId).getTable().getBinding("items").filter(new sap.ui.model.Filter(aFilters, true));
}
Thanks !!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
An easy way to refresh the list is:
this.byId("iList").getBinding("items").refresh();
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 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.