Skip to Content

sap.m.Table with get selected index

Dear All,

I need to created an application with similar to sap.m.Table but need to enable Row selection and to get GetSelectedIndex .

I just refered the smaples published through ;

SAPUI5 Explored

But though I am able to define a table , seems like there is no Row selection feature. can you please help

Thanx all in advance...

Table.PNG (33.8 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    Posted on Mar 27, 2015 at 11:50 AM

    Hello Tharaka, if you only need select a single row, then you can set mode SingleSelectmaster in your table.

    var oTable = new sap.m.table("oTable",{mode: sap.m.ListMode.SingleSelectMaster}

    For get index:

    oTable.attachSelectionChange(function(oEvent) {

    var oSelectedItem = oEvent.getParameter("listItem");

    var sItemName = oSelectedItem.getBindingContext().getProperty("yourpropertyname");

    alert(sItemName);

    }

    Full example: https://github.com/vobujs/UI5/tree/master/table/WebContent

    Another possible way is to put a button on one of the columns. In the event onPress of the button enter this code

    var buttonDetail = new sap.m.Button({

    icon: "sap-icon://action",

    type: sap.m.ButtonType.Emphasized,

    press: function(evt) {

    var idButton = this.sId;

    var arrayId = idButton.split("-");

    var tableIndex = arrayId[arrayId.length-1]; //get the row index

    oController.go___(evt, tableIndex);

    }

    });

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 27, 2015 at 07:01 AM

    SAPUI5 SDK - Demo Kit

    table.setMode(sap.m.ListMode.MultiSelect)

    or in xml

    <...mode="MultiSelect"

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 27, 2015 at 09:54 AM

    for js view,

    and in xml view,

    <Table id="idTable" mode="MultiSelect">

    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.