Styling table rows with embedded view columns

I have been trying to style a table component to change the color of rows that have a certain column value. This I can do fairly easily, but it breaks the embedded view that I have set on one of the columns. I believe this has something to do with the fact that I am going from a Dataset object to json. Here is the code to color the rows:

def transform(self, value, quality, timestamp):
	
	# This list will be used to create a JSON like structure that will insert rows for our styles
	output_json = []
	 
	# Here we can define what styling on our rows will be.
	style_green = {"backgroundColor": "#B0FFB5 "}
	 
	# You could change more than just the background color, for example:
	# style_another_example {"backgroundColor": "#00AA00", "font-weight": "bold"}
	 
	 
	for row in range(value.getRowCount()):
	    row_object = {}
	    row_value = {}
	    row_style = {}
	    for col in range(value.getColumnCount()):   
	        row_value[value.getColumnName(col)] = value.getValueAt(row, col)
	        row_object['value'] = row_value
	         
	        # Here we're checking the name of the column that we want to base our styling on.
	        if value.getColumnName(col) == 'resolution':
	         
	            # Here we're checking for individual values within the column, and applying styling
	            if value.getValueAt(row, col) != None:
	                row_style = style_green
	        row_object['style'] = row_style
	    output_json.append(row_object)
	#system.perspective.print(output_json)
	#system.perspective.print(type(output_json))
	return output_json

Here is the embedded view column:
image

It is supposed to autofill a value, which is the param that gets passed to the embedded view.

Before styling it works as is, but the styling breaks it. Any suggestions would be appreciated.

Where's the dataset coming from? The named query bindings have the option to return JSON rather than dataset. That might simplify things a bit.

I can't see the problem yet. Can you paste a few rows of the props.data output by the script transform?

The dataset is coming from a query binding, which returns as a dataset. Then I do the script transform to add the styling stuff. I'm fairly new to the json stuff so im not sure how I would go from returning it as a json directly and then adding the styling.

This is essentially one row of the output for the script transform.

'value': {u'quantity': u'300 ST', u'employeeNo': u'E27198', u'AUFNR': u'16753661', u'resolution': u'Consumption', u'unit': u'PC', u'jsonData': u'{"id": 281143, "resolution": "Consumption"}', u'station': u'M01', u'DateTimeStamp': 2024-05-18 06:10:50.483, u'replyStateMessage': u'Deficit of BA Unrestricted-use 300 PC : 0070340381 5612 281 307996', u'location': u'281', u'id': 281143, u'MATNR': u'0070340381', u'batchNumber': u'307996'}}, {'style': {'backgroundColor': '#B0FFB5 '},

I'm unsure if the issue is this one u'{"id": 281143, "resolution": "Consumption"}', which is supposed to be read in as a param to the embedded view as a json string and then decoded on the other side, but it doesn't receive the param after the styling is applied. It's just odd to me because it doesn't seem like this particular value is altered in any way so that's why I think it's an issue with the whole thing being altered so it doesn't know how to access the values or something

Hopefully this is enough information to help, thanks

What you've posted isn't valid JSON. It's missing the opening { and some of the other stuff looks funny.

Easy way:

  • Add in another table.
  • Copy the binding from the first onto the second and but edit the binding to return the data in JSON format with no script transform.
  • Then copy and paste one row of JSON in here.

this may help

A full row of json as requested:
{u'quantity': u'22 ST', u'employeeNo': u'', u'AUFNR': u'16697924', u'resolution': None, u'unit': u'PC', u'jsonData': u'{"id": 281838, "resolution": ""}', u'station': u'AR1', u'DateTimeStamp': 1716570762270L, u'replyStateMessage': u'Enter Movement Type', u'location': u'281', u'id': 281838, u'MATNR': u'0070460913', u'batchNumber': u'0024795642'}

this is the dataset returned in json format and then printed to console like:
system.perspective.print(table.props.data[0])

This works totally fine and I can easily apply the color styling to the rows with a similar method to how I did it above, but whether I return the dataset as a json directly or convert it the result is the same for me. That is, the embedded views are not being sent the column value they are supposed to receive, which is a json string like {"id":281838, "resolution":"Consumed"} that gets decoded in the embedded view. To be clear, this does work if the dataset is not styled, even if it is a json instead of a dataset