1
votes

I am using sap.m.Table to display some documents as a sap.m.Dialog.The UI looks as below: enter image description here

Everything works as expected but when I scroll to the last Item (growing=true) the table rerenders and moves back to the top. Ideally that would happen only when I refresh a model. I am using bindAggregation to bind the odataModel to the UI. Please see a snippet below (Note:Partial snippet).

var dialog = new Dialog({
  title: title,
  buttons: [
    new sap.m.Button({
      text: "{i18n>close}",
      press: function(oEvt) {
        dialog.close();
      }
    })
  ]
});

var table = new sap.m.Table({
  width: "100%",
  inset: true,
  growing: true,
  growingThreshold: 100,
  growingScrollToLoad: true
})

dialog.addContent(table);
if (!dialog.isOpen()) {
  dialog.open();
}

var oDModel = new ODataModel(kmURL, {
  json: true
});
oDModel.setDefaultBindingMode(sap.ui.model.BindingMode.OneWay);
table.setModel(oDModel);
var mParams = {
  path: "/DocumentQuerySet",
  template: template,
};
table.bindAggregation("items", mParams);

I think that bindAggregation internally refreshes the model which forces the table to rerender after every data call. How can I avoid the model to refresh/rerender the table so that it does not scroll to the top every time the user scrolls down to see more data.

Appreciate any help. Thanks.

1

1 Answers

2
votes

You could fix this problem by placing the Table control within a ScrollContainer. The ScrollContainer will handle the growing feature of the table, which causes the change in height of the control. This will retain the current position without moving back to the top.

....
var table = new sap.m.Table({
            width: "100%",
            inset: true,
            growing: true,
            growingThreshold: 100,
            growingScrollToLoad: true
        })

        var oScroll = new sap.m.ScrollContainer({
            width: "100%",
            height: "500px",
            vertical: true,
            content: table
        })

        dialog.addContent(oScroll);
  ....