Skip to Content

sap.ui.table - getSelectedIndices()

Hello,

I am working with sap ui table with multi selection possibility. I would like to access the data related to the user selected rows (I want to do it using getContextByIndex(rowIndex)).

I am using oTable.getSelectedIndices() to get the indices of rows selected by the user. But, somehow the indices are not the correct indices of the selected rows from the table and so I get the wrong data from the context binding.

I understand that this is because If the selected row is not with in the visible row count.

How can I get the correct / actual indices of the selected rows from the table ?

It would be great If I get some help or hints on this. Thank you :)

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Jun 29, 2017 at 06:03 PM

    Hello Guys,

    I have been researching around. I think, I have identified the issue after reading the below blog.

    https://github.com/SAP/openui5/issues/320

    The issue was because of the scrollbar and it didnt allow to scroll until the last row(all the available rows) of the table. This can happen because of the parameters which are used to calculate the scrollbar length. One of such is: variable row height.

    If the content of the rows in the table has different heights, then the scrollbar length is not set correctly. So, we see this different behaviour while scrolling.

    Solution:

    I have given a fixed row height in the table definition. Now, I could scrolldown all the available rows(until last row). With this, the selected row indices are fetched correctly.

    Please let me know If I am leading in a wrong direction. Thank you :)

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 30, 2017 at 01:21 PM

    Hi

    you can get with

    			var oList = new sap.m.List();
    			oList = this.getView().byId("tableId");
    			var obj = oList.getSelectedItems();
    
    Add comment
    10|10000 characters needed characters exceeded

    • Hello....

      Thanks for your solution.

      I think, your answer is totally in other direction.

      My question was related to sap.ui.table. I think you solution might be for sap.m.table.

      But anyhow, I was able to find the solution and please see my answer for my exact problem.