v8.1.24
This was a bug in earlier versions I remember for some things but I thought it was fixed.
When referring to <table>.props.data
in script which is a list of objects, the object key values are read in as ImmutableQualifiedValues instead of as basic data types.
This makes manipulating it hard.. I just want to write to some of the item key values, but I get immutable errors:
TypeError: 'com.inductiveautomation.perspective.common.ImmutableQualifiedValue' object does not support item assignment
If I print the type and value of props.data[0] for example, I get this:
13:30:48.108 [Browser Thread: 54902] INFO Perspective.Designer.Workspace - class com.inductiveautomation.perspective.common.ImmutableQualifiedValue
13:30:48.110 [Browser Thread: 54902] INFO Perspective.Designer.Workspace - QV[{part_length=[2600, Good_Unspecified, Fri Feb 03 13:26:32 ACDT 2023 (1675392992119)], select=[false, Good_Unspecified, Fri Feb 03 13:26:32 ACDT 2023 (1675392992119)], job_name=[310822-WGND-001, Good_Unspecified, Fri
I'm actually struggling to convert this to something I can actually use
2 Likes
Hmm. What's the source of the data in the table?
When I do it off the basic data in the table, I get the 'object wrapper' I would expect; that is:
system.perspective.print(self.getSibling("Table").props.data[0])
outputs:
09:20:17.872 [Browser Thread: a09cdd3b-7f7d-48ec-bb06-ec6c75d65555] INFO Perspective.Designer.Workspace - <ObjectWrapper>: {u'country': u'United States', u'city': {u'editable': True, u'justify': u'left', u'style': {u'backgroundColor': u'#F7901D', u'classes': u'some-class'}, u'align': u'center', u'value': u'Folsom'}, u'population': 77271L}
So what might be happening is that a specific binding or script source is putting the data onto the table in an odd way?
Hmm, interesting, I'll have a look!
Don't have much time, but this is what populates it:
try:
job_name = payload['job_name']
job_parts = payload['job_parts']
items = []
items.extend([{'job_name': job_name,
'job_part': job_part['part_name'],
'job_part_operation_csv': job_part['operation_csv'],
'part_type': job_part['part_type'],
'part_length': job_part['part_length'],
'select': False,
'row': row,
'last_run_on': job_part['last_run_on']
} for row, job_part in enumerate(job_parts)])
self.props.data = items
self.parent.custom.selectedJobName = job_name
except:
shared.fe.perspective.error.displayError()
1 Like
I dunno. I set up a message handler and a direct script and tried to populate a table with similar data, but both worked and gave me objectwrappers in the output. I thought it might be something with deeply-nested object references or something also, but I didn't have any luck. If you can provide an SSCCE here or to support, it'd be great.