Hello, I've been working on this for few days and I think I'm getting close to a solution but I need some guidance. I do want to stress that I am not using a binding. I am running a preped query, the user types into a text box and then clicks a button.
Here is my code:
newData =[]
# RUNNING QUERY
results = system.db.runPrepQuery("SELECT .... MY QUERY", [txt])
# EDIT TABLE BASED ON VALUES
for row in results:
system.perspective.print(row)
for col in row:
system.perspective.print(col)
cell = row[4] # Accessing the 'Status' column value
row[4] = {"value": "Old", "style": {"backgrounColor": "#00FF00"}}
newData.append(row)
# POPULATE TABLE WITH QUERY RESULTS
self.getSibling("Table").props.data = results
The 4 is the column I am examining.
Here is a link to where I was pulling my information form: Link
Here is the error I get:
Traceback (most recent call last):
File "<function:runAction>", line 29, in runAction
TypeError: can't assign to immutable object
I eventually realized that everyone is using bindings and a JSON format, so I ran this piece of code so that I get a JSON return format:
results = system.util.jsonEncode(system.dataset.toPyDataSet(system.db.runPrepQuery("SELECT ... MY QUERY, [txt], )))
newData =[]
# EDIT TABLE BASED ON VALUES
for row in results:
system.perspective.print(row)
for col in row:
system.perspective.print(col)
cell = row[col] # Accessing the 'Status' column value
row[col] = {"value": "Old", "style": {"backgrounColor": "#00FF00"}}
newData.append(row)
# POPULATE TABLE WITH QUERY RESULTS
self.getSibling("Table").props.data = newData
If I use [col] instead of [4] I get this error:
File "<function:runAction>", line 32, in runAction
TypeError: unicode indices must be integers
If I use [4] instead of [col] I get this error:
File "<function:runAction>", line 32, in runAction
IndexError: index out of range: 4
LASTLY THE TABLE DOESN'T GET POPULATED AND HERE IS WHAT IT LOOKS LIKE