i have a question regarding color cell,
i did wrote a script to color the column that start with !
.
im using _grist_Tables_column, and it works for all table, however, i have a table that is not working, when i test on web with inspect console open, all are using patch _grist_Tables_column, but this one is using _grist_Views_section_field to update. is it maybe i ruined the table properties while i’m testing? or i’m missing something else?
table = "Table1"
# get id of table
req = requests.get(
f"https://docs.getgrist.com/api/docs/{document_id}/tables/",
headers=headers,
)
data = json.loads(req.content)
for dt in data["tables"]:
if dt["id"] == table:
id = dt["fields"]["primaryViewId"]
print(id)
req = requests.get(
f"https://docs.getgrist.com/api/docs/{document_id}/tables/_grist_Tables_column/records",
headers=headers,
)
data = json.loads(req.content)
# make each col has widgetoption color #f0f if start with '!'
columns = []
for dt in data["records"]:
if dt["fields"]["parentId"] == id and dt["fields"]["label"].startswith("!"):
obj = {
"id": dt["id"],
"fields": {
"widgetOptions": '{"widget":"TextBox","alignment":"left","fillColor":"#F0F"}'
},
}
columns.append(obj)
records = {"records": columns}
print(records)
# patch
req = requests.patch(
f"https://docs.getgrist.com/api/docs/{document_id}/tables/_grist_Tables_column/records",
headers=headers,
json=records,
)
data = json.loads(req.content)
print(data)