cancel
Showing results for 
Search instead for 
Did you mean: 

Prevent automatic OData request at application startup

Dear experts,

in the SAPUI5 Walkthrough Step 26 it is well described how to consume a remote web service. You can find the example and the source here .

So far so good,I tried to implemented it, and everything is working well. Now, my customer have a special requirement:

They don't want the invoices list to be populated automatically at application startup. The first OData request, shall be performed when entering some key words at the top level search bar. I could successfully implement an onSearch event and fetch the reduced dataset from the server but I could not prevent the initial request when loading the application. I tried to disable the preload flag at the model descriptor:

		"invoice": {
				"dataSource": "invoiceRemote",
                                "preload"   : false
			}

Unfortunately it doesn't help. How can I prevent the initial server request at startup?

Thanks in advance!

Accepted Solutions (1)

Accepted Solutions (1)

I found a working solution. Remove the model descriptor from the manifest.json and create a new model instance at the search event method in the corresponding view controller:

		onSearchInvoices : function (oEvent) {
			var oModel = new sap.ui.model.odata.v2.ODataModel("your/remote/service/path");
			var oFilter = new Filter("SearchFilter", "EQ", "SomeFilterValue");
			oModel.read("/YourEntitySet", { filters : [oFilter] } );
			this.getView().setModel(oModel,"YourModelID");
		}

Answers (0)