Color Columns API

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?

image

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)

Hi @Ghady_Gergie,

Grist columns can appear in one more more views (e.g. table, card, etc.). By default, column settings such as cell style are shared across all views. There is an option in the right panel to use separate settings; when enabled, it causes changes to that specific column’s configuration to not apply to the same column in other views.

These are called “fields”, and they relate to columns in that each column can have multiple fields (one in each view), but each field belongs to exactly one column.

I’ve attached a screenshot of the setting below. Could you check if your column is using separate settings? That would explain why it’s updating _grist_Views_section_field if so.

Screenshot 2024-07-31 at 2.59.47 PM

George