cancel
Showing results for 
Search instead for 
Did you mean: 

Fiori - Rebind Line Item after Function Import

06-15-2018 4:24 PM
alexandredoyen Explorer
2515 views 3 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

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 !!

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

alexandredoyen
Explorer

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 !!

Answers (1)

Answers (1)

CristianBabei
Contributor

An easy way to refresh the list is:

this.byId("iList").getBinding("items").refresh();

alexandredoyen
Explorer
0 Likes

Thank you Cristian, but I try to refresh binding on LineItem from annotation and, now, syntax getBinding("items") does not work 😕

I am still working on it.

Thanks again for helping 🙂