Perspective binded table pass selected row/column data to subview

I am trying to pass data to a subview with a table binded to a query with parameters. So far I have been able to pass data but not the data of the selected row. I tried binding a parameter with this expression:

toString({this.props.data}[1, “Work Order”])

This returns only the first rows “Work Order” data, but I need it to return whichever row is selected. I tried a few different things with no desired results.

toString({this.props.data.getValueAt(table.selectedRow,table.selectedColumn)})

toString({this.props.data}[({this.props.data.selectedRow}), “Work Order”])

image

We provide an example of how to do this in the documentation.

Long story short:
The View you will be using for the SubView should have only one parameter, and that parameter should be named value. This value parameter should be an object type, and it should have as many keys as you have columns for the Table. Each internal key of the value param should be a case-sensitive match for the column keys of your data.

So, assuming your columns in the image are aliases and you actually have column keys of “work_order” and “type”, you should have a param named value with internal keys of “work_order” and “type”, like so:
Screen Shot 2021-09-19 at 11.11.10 PM

You should NOT be applying any additional bindings to get this to work. The Table will automatically pass all of the data of the row into the subview via the value param.

2 Likes

I tried doing what the documentation said with no results, thats when I treid using the expressions. I followed your instructions with no results. Tried binding the subview views parameter to the query parameter with no luck either.

This is the query from the main table containing the subview
image

This is the subview view params
image

This is the subview view params binded to the views query binded table parameter

Your subview is expecting a parameter named wo_id, but your primary table has the column named Work Order. Try removing as Work Order from the main tables query.

1 Like

As @schenk described, the actual object for every entry in your data array looks to probably have the following structure:

data: [
    {
        "Work Order": 123456,
        "Type": "Something"
    }
]

So your Subview should expect a param of this shape:

value: {
    "Work Order": "value"
    "Type": "value"
}

Although, a word of warning: you should try to avoid keys with spaces. Perspective has had trouble in the past with keys which contain spaces. We’ve done a lot fo work safeguarding against spaces in property keys, but every now and then you’ll find something which just doesn’t work with spaces in such a key.

I got it to work thanks to everyone advice. Thanks!