Select all the rows in a Table via script

Hi,
I'd like to know how I can select all the rows in a Table via script, so that I can delete them.
Thanks.

Delete them as in remove them from the table, or Delete them as in remove them from a Database or other data source?

All rows from a table should be in the props.data property.

Here's how to do it from a button event.

self.getSibling("Table").props.data = []

Hi, I tried this method, but it didn't work for me.

I just want to select all the rows via script. After that, I have other scripts that work with this selected information. In my project I can reload or delete what has been selected.
I want to select the rows as I would do manually with the mouse, having the mode configured as multiple interval.
It would be the same as clicking on the First line + Shift key + Last Line. All rows are selected then.
Thanks.

What didn't work? Why didn't it work?

props.data is all rows in the table.

Why would it matter if the mode is configured as multiple interval or not? You stated you wanted all rows.

I feel like either there is missing context or you're not asking the question that we think you are.

1 Like

I tried what @Transistor suggested, but the rows were not selected. On the contrary, I got "null" at the selectedColumn and selectedRow parameters.
When I press the "Select All" button in my project I want to visually see all rows selected. That's why it should be configured to multiple interval.
I have the option to manually select individual rows, or select them all at once in a button. After that I get the select rows to reload them, actually not to delete them.

@Transistor wasn't showing how to select them. They were showing how to Delete them.

Am I correct in saying that you don't always want to delete them?

Selecting all rows is a Single Interval. Multiple Interval means that you can have multiple groups of continuous rows selected. (e.g. Row 1-3 is selected, Row 4 is skipped, Row 5-6 is selected).

If you want to manually select all rows (so that they are shown as selected on the UI) I believe that you only need to set the props.selection.data equal to props.data. I haven't tested that though.

self.getSibling("Table").props.selection.data = self.getSibling("Table").props.data does copy the data but doesn't highlight the rows. Hmmm.

Hi, I had a better look in my project and then I could see that actually I don't delet the selected rows, I only have the option to reload the information.

This project was done in Vision an now is being set up in Perspective.
In vision was used the "List" component, but since I don't have this in Perspective I have to use a table, I guess.
In vision after selecting manually the rows or pressing the "Select All" button, there was a button named "Reload", where is used the funcion event.source.parent.getComponent('List').getSelectedValues().

In Vision at the button "Select All", this is the script:

listElement = event.source.parent.getComponent('List')
data = listElement.data

data.rowCount

listElement.addSelectionInterval( 0, data.rowCount -1 )

I'm trying to replicate this in Perspective. I do not know if there is a similar way to do it in a table.
Thanks.

I think you're trying to replicate this in Perspective.

Tip: use the </> code formatting button to preserve code indentation and apply syntax highlighting. It's essential for Python and makes any code much easier to read. There's an edit button 🖉 below your post so you can fix it.

Thanks for the tips. That's right, I'm trying to replicate this in Perspective.

Hi,

For that I prefer the check box, For highlighting the selection i using the transform.
When you click on the button for select all, Updating the check box with true. then in the submit, check the check box is true or not, all true record you can made the transaction try it.

Thanks