Skip to Content

Fiori - Rebind Line Item after Function Import

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

capture.png (27.6 kB)
Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Jun 29, 2018 at 01:37 PM

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

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 18, 2018 at 07:53 AM

    An easy way to refresh the list is:

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

    Add comment
    10|10000 characters needed characters exceeded