Warm tip: This article is reproduced from stackoverflow.com, please click
sap-fiori sapui5 scrollbar

Scrollbar is not displayed in sap.m.table

发布于 2020-04-22 10:42:58

I am using an sap.m.table. The number of rows is too big to fit on the page. Therefore, I expect the table to offer a scrollbar. But that is not the case.

UI5 Version: 1.68.1 Tested in Edge, Firefox, Chrome.

Here is a simple demo app displaying 1 Table with 1 column and 25 rows. Only first 18 items fit on the screen but no scrollbar is offered:

App.controller.js

sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "sap/ui/model/json/JSONModel",
], function(Controller, JSONModel) {
    "use strict";

    return Controller.extend("TableTest.controller.App", {

        onInit: function() {

            var data = {
                items: [
                    {
                        name: "item1"
                    },
                    {
                        name: "item2"
                    },
                    {
                        name: "item3"
                    },
                    ...
                ]
            };
            var oModel = new JSONModel(data);
            this.getView().setModel(oModel);

        }

    });
});

App.view.xml

<mvc:View 
    controllerName="TableTest.controller.App" 
    xmlns:mvc="sap.ui.core.mvc"
    xmlns="sap.m">
    <Table
        id="table"
        items="{/items}">
        <headerToolbar>
            <Toolbar>
                <content>
                    <Title text="sap.m.Table"/>
                </content>
            </Toolbar>
        </headerToolbar>
        <columns>
            <Column>
                <Text text="Name"/>
            </Column>
        </columns>
        <items>
            <ColumnListItem>
                <cells>
                    <Text text="{name}"/>
                </cells>
            </ColumnListItem>
        </items>

    </Table>
</mvc:View>

Result Result

Questioner
Peter Petrus
Viewed
115
Cmdd 2020-02-06 22:35

I'm guessing you are launching your app with the Component.js as entry point so in your App.view.xml wrap your table in

<Shell id="shell">
    <App id="app">
        <pages>
            <Page id="page" title="{i18n>title}">
                <content>
                    //your table here
                </content>
            </Page>
        </pages>
    </App>
</Shell>