Skip to Content
0
Nov 05, 2020 at 02:47 PM

SPUI5-Table Select Multiple Rows

239 Views Last edit Nov 05, 2020 at 02:54 PM 3 rev

Dear Experts,

I'm using sap.ui.table for table selection.

I was trying to populate rows for selected indexes.

selectTableList: function (tableId, selectionList, selectionModel) {
      var selectData = selectionModel.getData(); 
      var selectionListNames = selectionList.split(","); 
       for (var i = 0; i < selectionListNames.length; i++) {
              for (var j = 0; j < selectData.length; j++) {
                    if (selectData[j]["Name"].trim() === selectionListNames[i].trim()) {
                        var oTable = this.getView().byId(tableId); 
                        oTable.addSelectionInterval(0, j);
                     }
               }
        }
},

above code selecting the from index 0 to till J, but i need only few rows to be selected for that i have used below code but it displays data but nothing is selected.

selectTableList: function (tableId, selectionList, selectionModel) {
                            var selectData = selectionModel.getData();
                            var selectionListNames = selectionList.split(",");
                            for (var i = 0; i < selectionListNames.length; i++) {
                                 for (var j = 0; j < selectData.length; j++) {
                                  if (selectData[j]["Name"].trim() === selectionListNames[i].trim()) {
                                      var oTable = this.getView().byId(tableId); 
                                       oTable.addRow(j);

                                     }
                                  }
                            }

},