Skip to Content

Scroll in sap.m.table

I have extended an programm which displays data in an sap.m.table.

Part of the extension is to add new lines to the model /table.

// Get tab

var element = sap.ui.getCore().getElementById("Install_Data");

var oModel = element.getModel();

var test = oModel.getProperty("/GetLvmSolutionInstallationMapping/");

var inp = sap.ui.getCore().getElementById("Input_Data");

var iModel = inp.getModel();

var inptest = iModel.getProperty("/GetLvmSolutionInstallationMapping/0");

if (inptest.SolutionCode != ""){

var new_obj = JSON.parse(JSON.stringify(inptest ));

new_obj.UpdateFlag = true;

test.push(new_obj);

oModel.setProperty("/GetLvmSolutionInstallationMapping/", test);

}

After some problems it works fine. Since the table is greater then the display its necessary to position the table on the new item.

After looking in SCN i found the following solution

var oItem = element.getItems()[new_Item_index];

var oScroll = sap.ui.getCore().getElementById("IDHECINSTSCROLL");

oScroll.scrollToElement(oItem);

My problem is it doesnt work. When executing the code there is an error "scrollToElement" is not a function. It seems that the version of the sap.m.Scrollcontainer doesnt know the scrollToElement function.

I use a sap.m.table within a sap.mScrollcontainer for scrolling which is on a sap.m.Page with scrolling disabled.

Since i cant change that version at the moment is there any other way to position the table on the new line?

Regards.

Dirk

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Nov 13, 2015 at 11:47 AM

    Please check this example. its should be useful S Bin - Collaborative JavaScript Debugging


    Kindly let me know if you need any more information.

    Add a comment
    10|10000 characters needed characters exceeded

    • Could you please check this simple code for "Scroll" in table

      var oTable = new sap.m.Table({

      columns : [ new sap.m.Column({

      header : new sap.m.Label({text : "List"})

      })]

      });

      oTable.bindItems("/", new sap.m.ColumnListItem({

      cells : [ new sap.m.Text({text : "{name}"})]

      }));

      var oModel = new sap.ui.model.json.JSONModel(data);

      oTable.setModel(oModel);

      var scroll = new sap.m.ScrollContainer({

      width : "200px",

      height: '100%',

      vertical :true

      });

      scroll.addContent(oTable);

      scroll.placeAt("content");
  • Posted on Nov 13, 2015 at 02:06 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 13, 2015 at 02:07 PM

    scrollToElement is method of the sap.m.Page

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 14, 2015 at 05:40 AM

    Hi Dirk,

    Yes, you are right!

    scrollToElement method is introduced from 1.30 version - JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.m.ScrollContainer

    I guess you are using lower library version. But, you can give a try with scrollTo method - JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.m.ScrollContainer

    Not sure when this method got introduced. Since, it is not mentioned in the API as well.

    I created a JSBin using .scrollTo method, you can have a look: JS Bin - Collaborative JavaScript Debugging

    Regards,

    Sai Vellanki.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.