Hi There,
I’m looking to get icons to appear in my table. I’ve set a template screen for the icon and I’d like to change this icon based on row information in the table. I’ve tried to add a dictionary to the data param but I don’t think this was the intended way to achieve this. Any help would be appreciated.
1 Like
The row’s data will automatically get passed as params to your view. If it is a view cell, which is what you have, the shape should be:
column: number,
columnIndex: number,
row: number,
rowIndex: number,
value: any,
rowData: object,
the rest of any custom params provided through configuration
Pro tip, if you end up in this situation again, it’s useful to drop a markdown or text area component and just bind its value to the views params to see what params are getting passed to your view.
2 Likes
Hi,
How can you get output values from your row view ?
For example I use a dropdown list in a row view. I would like to retrieve the selected value in my table.
Thanks.
You can bind a view custom param set to output mode to the dropdown selected property
1 Like
I did this but I don’t retrieve my output variable in my table.props.data property below (outputValue) whereas it works in my embedded view.
Another question : Is it possible to dynamically change row height ? Some rows have view just showing a dropdown list (small height) and others tables (big height).
What I have done to get an embedded dropdown to be able to modify my table’s props.data property in the past is add a change script to the dropdown’s value property that sends a message out with a payload that contains your updated value from the dropdown as well as some identifier specific to the row that you can use to locate the correct row to update its value. My script on the dropdown component would look something like this:
value = currentValue.value
if value is not None:
if 'Binding' not in str(origin):
msg = 'UpdateRow'
name = self.view.params.rowData['name']
payload = {
'value' : value,
'name' : name
}
system.perspective.sendMessage(msg, payload)
Then I would create a message handler on the table view that loops through the rows of table.props.data and checks if the payload from any message received contains the identifier mentioned above (the name column, in my example) and if so, update the value of your dropdown column for that row. Something like:
newData = []
rowName = str(payload['name'])
value = payload['value']
data = self.getChild("Table").props.data
for row in range(len(data)):
newRow = dict(data[row])
if str(data[row]['name']) == rowName:
newRow['dropdownColumn'] = value
newData.append(newRow)
self.getChild("Table").props.data = newData
Thanks
I have the error below
[Browser Events Thread] INFO Perspective.Designer.BrowserConsole - [mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: 'Reaction[viewstore-output-listener]
Is there a discrepancy between what you named your message handler on the table view and what is being called from the dropdown value’s on change script? I also placed the message handler on the root of the view containing my table component, so if your handler or table are located elsewhere, directly copying the script above would not write back to the table’s data property unless you changed the references to the data property on lines 4 and 10 of the second script example.
I’ll attach a test view I made that appears to be working and maybe you can compare it to your table to help see what could be different between the two.
Table_Dropdown_Example.zip (37.1 KB)
1 Like
I’ve changed your onMessageReceived script. It works better for me because it updates only desired variables.
newData = []
rowName = str(payload['name'])
value = payload['value']
data = self.getChild("Table").props.data
for row in range(len(data)):
if str(data[row]['name']) == rowName:
data[row]['dropdownColumn']=value
Does this still work? I'm having issues binding a Markdown to view.params
You can’t bind directly to the params property, i’m pretty sure @ynejati meant to bind to the individual params to see their values. Although I’ve always thought binding to the params to get everything would be super useful
1 Like
Oh ok. I read it as if you don’t know what you’re getting then bind the view.params to see what you’re getting.
I ran into the same hurdle yesterday, I know the row data was implicitly passed in like a subView or dynamic column View but I couldn’t figure out the key. I checked the docs and it didn’t give me enough information.
This page could be updated to help someone in the future;
https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Table
Snippet:
and of course I was looking for rowData which I found in this post.