How to find the index of click row when row select change in new table

How to find the index of click row(not click select check box) in js block when row select change in new table.
Yes I know selectedDataIndexnumber and selectedDataIndexes.

how to write and express to get index of clicked row?
table1.selectRow([...table1.selectedDataIndexes,currentClickIndex ]);

My use case is similar to Select single row with checkbox

I want to find the index of row when click, and add it to current selection.

Also table1.selectRow([1,2]) seem not work in new table which multi-select is enable.

1 Like

Hey @AnsonHwang. Interesting question regarding my post Select single row with checkbox

:grinning:

Patrick

Hi Anson,

selectRow works a bit differently in the new table. You can use this general syntax:

table1.selectRow({ mode: "index", indexType: "data", index: [3, 4] });

For the clicked row, it seems like you can use currentRow to get the clicked item:

Would this click event work for you? Keep in mind that - depending on your use case - you'd likely want to add logic to this example for de-selecting a row

Thanks for your reply.
I don't know selectRow can use in this way. Maybe add the code above to the docs will be good.

In the docs it said There are two modes you can use to specify the row: key and index. Use key to pass the primary key to select the row. Otherwise, use index and pass an indexType to select a row. It seem suggest that if you use key mode, you can't pass and IndexType to it neither an array of index.

1 Like

If I want to use mode of index. How should I get the index of displayed item instead of index of source data?

Also selectedDataIndexes should be renamed to selectedSourceDataIndexes to better recognize?

Consider adding selectedDisplayedDataIndexes ?

Yes, if you're using key, you won't need indexType or index, just an array of keys:

1 Like

It's a good question/point of feedback for the data index and displayed data index! I'll share this internally as a feature request