Select single row with checkbox

Hello,

I'm looking for a way to have the checkbox of "Multiple selection" in a "Single select" way.

Let me explain: So, when I click on a row in the table this should happen:

If I now click on the row below the selected row, this should happen:

So, the selection checkbox should ONLY select the last clicked row. If I need to select more than one row, I should click on the checkboxes in the first column.

So, clicking on a row selects only ONE row at a time, clicking on the checkboxes itself selects multiple rows.

How can I achieve this?

Thanks! And than you for a great tool!! :pray:

Patrick

Here is solution.

table1.selectRow({ mode: "key", key: currentRow.id});

You may notice that, I listen to the Double click row instead of row click, because if I choice (single) row click, it means even I click the checkbox at the first column, the handler of row click is still run, which will result select single only. You can't select multi by check the checkbox.

If you still want to find a way to use single click, you may change the table to enable cell click

but there is trick here

the console.log(arguments) is show as following
image

as you see, you can use table1, item(its the value of the cell you clicked), currentSourceRow, currentRow, seft(maybe the same as table1?) in your cell click handler scope.

You can use the above variable to construct you logic on the cell click event handler.

Hope this can help you.

1 Like

I'd recommend testing this idea further, but I think this would also work :crossed_fingers::

Create an event handler that only runs when there is a selectedCell (if you click the checkbox, it doesn't seem to impact the selectedCell property)

1 Like

Great idea @Tess, thanks! :pray: