cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP RAP and oData v4 max items (or growing threshold) is not available

Louis-Arnaud
Participant
757

Hello,

I am trying to change the growing threshold of the object page table in a RAP application using OData v4 (as recommended, to the best of my knowledge).

The annotation @ui.presentationVariant with maxItems is not working. I also tried editing the page in Visual Studio Code through the page editor, but the Growing threshold attribute does not exist (I assume this is because I am using OData v4).

"So be it," I thought. No worries—I can create a controller extension and change this parameter with JavaScript. But no! Controller extensions are not available with OData v4.

Am I missing something? The default growing threshold on the object page is 10, which is quite limited.

Why is OData v4 missing so many features?

View Entire Topic
Sapdreas
Explorer
0 Kudos

Hi, 

i got the same problem and found a solution.

Extend the controller with the guided development.
(The Controller for the Object Page with the Table you want to modify)
Add this code:

Replace the XXXXX with your correct controller name

sap.ui.define([
	"sap/ui/core/mvc/ControllerExtension"
], function (ControllerExtension) {
	"use strict";

	return ControllerExtension.extend("XXXXX.ext.controller.Header_Page_Controller_Extension", {


		override: {

			onInit: function () {

				var oModel = this.base.getExtensionAPI().getModel();
			},

			onAfterRendering: function () {
				var oTable = this._getObjectPageTable();
				if (oTable) {
					oTable.setGrowing(true);
					oTable.setGrowingScrollToLoad(true);
					oTable.setGrowingThreshold(50);
				}
			}
		},

		_getObjectPageTable: function () {

			var oView = this.getView();

			var aTables = oView.findAggregatedObjects(true, function (oControl) {
				return oControl.isA("sap.m.Table");
			});

			return (aTables && aTables.length) ? aTables[0] : null;
		}

	});
});