[SOLVED] Remove row on cell select - help!

I have a table that populates in the member section and is filtered to the owner. What I am trying to achieve is to have the owner select a row in the table and have it remove from the dataset, then refresh. I am trying to accomplish this from onCellSelect so that I can control how the rows get removed. If cell value equals ‘Leave class’, then it removes row containing the selected cell.

I believe I’m close, but am not sure. Code below removes row, but only the first (current?) row and not that of the selected cell. The popup notice also flashes in and out quickly, but unsure how or where to place in the code to have it perform correctly:

In case anyone stumbles across this thread and looking for the solution:

I was able to get the correct row removed using on cell select if that cell value equaled ‘Leave class’. I created const index that equaled the cell’s row index, then another const id that included that index value with the target rows id. Then just set the remove to that const id.

Here’s the snippet of updated code:

let fitClass = event.cellData;
const index = event.cellRowIndex;
const idToDelete = event.target.rows[index]._id;
if (fitClass === ‘Leave class’){
wixData.remove(‘FitnessSignup’, idToDelete)

2 Likes

Awesome!

I wrote a little function that you can call from a specific column, hope this helps someone:

//Listen to cellSelect
export function tableRepeater_cellSelect(event) {
  //Put existing table into an array to be able to splice it
  let filteredData = $w("#tableRepeater").rows;
  //Splice out the selected row by using row index from event 
  let cellRowIndex = event.cellRowIndex; 
  //Only splice the one row which was selected
  filteredData.splice(cellRowIndex, 1); 
  //Handler respond with any cell clicked upon, just choose one that you like to have this feature
  if (event.cellColumnId === "ColumnNameHere") { 
    //Fill up the table with new fresh rows
    $w("#applicantsRepeater").rows = filteredData; 
    //Good to go! Have fun WiXing :D 
  }

please help me to with a code to delecte a selected row with confirmation message which should also trigger to refresh the table ?