Number of selected rows in Perspective Table component?

I am trying to return the number of selected rows of a Perspective table component in a script. If I select more than one row, such that the “data” property has a length of grater than 1:

then I use the “len” operator:

Names = [self.getSibling("Table_Ballot").props.selection.data]
logger = system.util.getLogger("myLogger")
logger.info(str(Names) + " len " + str(len(Names)))

it only returns a “len” of 1 no mater how many rows I have selected

log output with 1 selected:
[: [: {u’Name’: u’Joan’}]] len 1

log output with 2 selected:
[: [: {u’Name’: u’Dennis’}, : {u’Name’: u’Steve’}]] len 1

log output with 3 selected:
[: [: {u’Name’: u’Steve’}, : {u’Name’: u’Dennis’}, : {u’Name’: u’Joan’}]] len 1

log output with 4 selected:
[: [: {u’Name’: u’Steve’}, : {u’Name’: u’Fido’}, : {u’Name’: u’Dennis’}, : {u’Name’: u’Joan’}]] len 1

In all cases, “len” returned 1. Is there some other way of getting the number of selected rows?

Get rid of the outer brackets. You are putting the contents of data into a list.

2 Likes

Thanks, that did it. So the brackets copy the structure but without the brackets it copies the data?

No. In python, brackets = list.
The data property is a list. You are putting a list inside a list. You have 1 item (data) in the list Names