SAP UI5. Limiting the Number of Records Displayed in a List

SAP UI5. Limiting the Number of Records Displayed in a List from the Data Model

If your SAPUI5 application’s data model contains more than 100 records, and you use a List element in the view to display them, you will most likely not see all the records from the model as a result of the binding.

See: Data Binding

The number of records displayed can be controlled. Let me walk you through a small example.

OData Service

We have an OData service that processes data from a custom table containing more than 100 records.

0:00
/0:58

SAPUI5 Application

In the SAPUI5 application, I prepare a data model whose records should be displayed in the frontend using a List element.

0:00
/1:17

As shown above, only 100 records are displayed in the view. One might assume that the remaining 200 were not added to the model for some reason. In the following video clip, I will demonstrate that this is not the case.

0:00
/0:57

All 300 records were indeed received from the backend system.

What Happened Then?

The limit on the number of records used for binding was triggered—this limit is 100.

See: class sap.ui.model.Model
Set the maximum number of entries which are used for list bindings.
The default size limit for models is 100.

Changing the Number of Records Displayed from the Data Model

You can control how many records are involved in the display by calling the setSizeLimit method:

onInit: function() {
 
            var sUrl = "/sap/opu/odata/SAP/ZAPP14_SRV_01/";
            var oDataModel = new sap.ui.model.odata.v2.ODataModel(sUrl, {
                json: true,
                loadMetadataAsync: true
            });
 
            var oModel = new sap.ui.model.json.JSONModel();
            oDataModel.read("/countSet", {
                success: function(oData, response) {
                    oModel.setData(oData);
                }
            });
            oModel.setSizeLimit(300);
            this.getView().setModel(oModel, "count");
        }

Checking

0:00
/0:55