set_visible_columns
Control column visibility in table views by setting visible-columns annotations. Define which columns show in each UI context, with changes staged until applied.
Instructions
Set the visible-columns annotation on a table.
Controls which columns appear in different UI contexts and their order. Changes are staged locally until apply_annotations() is called.
Args: table_name: Name of the table. annotation: The visible-columns annotation value. Set to null/None to remove.
Visible-Columns Annotation Schema (tag:isrd.isi.edu,2016:visible-columns):
{
"compact": [...], // Columns for compact/list view
"detailed": [...], // Columns for detailed/record view
"entry": [...], // Columns for data entry (create/edit)
"entry/create": [...], // Columns for create only
"entry/edit": [...], // Columns for edit only
"export": [...], // Columns for export
"filter": { // Faceted search configuration
"and": [...]
},
"*": [...] // Default for all contexts
}Column directive formats (items in column lists):
Simple column name (string):
"RID"Foreign key reference (array of [schema, constraint_name]):
["schema_name", "fkey_constraint_name"]Pseudo-column (object with source path):
{ "source": "column_name", // Simple column "source": [ // Or path through foreign keys {"outbound": ["schema", "fkey"]}, "target_column" ], "sourcekey": "predefined_key", // OR reference to source-definitions "entity": true, // Show as entity (row) vs scalar value "aggregate": "array", // Aggregation: min, max, cnt, cnt_d, array, array_d "self_link": true, // Link to current row "markdown_name": "Display Name", // Custom column header "comment": "Tooltip text", // Column tooltip "display": { // Display options "markdown_pattern": "{{{value}}}", "template_engine": "handlebars", // or "mustache" "show_foreign_key_link": true, "array_ux_mode": "csv" // raw, csv, olist, ulist } }
Filter context (for faceted search):
{
"filter": {
"and": [
{
"source": "column_name",
"markdown_name": "Filter Label",
"open": true, // Expand by default
"ux_mode": "choices", // choices, ranges, check_presence
"bar_plot": true, // Show distribution chart
"hide_null_choice": true, // Hide "No value" option
"choices": ["val1", "val2"], // Preset choices
"ranges": [{"min": 0, "max": 100}] // Preset ranges
}
]
}
}Returns: JSON with status and the table name.
Examples: # Simple column list for compact view set_visible_columns("Image", { "compact": ["RID", "Filename", "Subject"], "detailed": ["RID", "Filename", "Subject", "Description", "URL"] })
# Include foreign key as a column
set_visible_columns("Image", {
"compact": ["Filename", ["domain", "Image_Subject_fkey"]]
})
# Pseudo-column traversing foreign key
set_visible_columns("Image", {
"detailed": [
"Filename",
{
"source": [{"outbound": ["domain", "Image_Subject_fkey"]}, "Name"],
"markdown_name": "Subject Name"
}
]
})
# Configure faceted search
set_visible_columns("Image", {
"filter": {
"and": [
{"source": "Species", "open": true},
{"source": "Quality", "ux_mode": "choices"}
]
}
})
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| annotation | No | ||
| table_name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |