add_visible_column
Add a column to the visible-columns list for a context in Deriva, handling plain names, foreign keys, or pseudo-columns. Staged until apply_annotations is called.
Instructions
Add a column to the visible-columns list for a specific context.
This is a convenience tool for adding columns without replacing the entire visible-columns annotation. Changes are staged until apply_annotations() is called.
Args: table_name: Name of the table. context: The context to modify. See Contexts below. column: Column to add. Can be: - String: column name (e.g., "Filename") - List: foreign key reference (e.g., ["schema", "fkey_name"]) - Dict: pseudo-column definition (see set_visible_columns) position: Position to insert at (0-indexed). If None, appends to end.
Contexts for visible-columns:
Context | Description | When Used |
| Default for all contexts | Fallback when specific context not set |
| List/table view | Main record list, search results |
| Abbreviated list | Inline previews, tooltips |
| Minimal inline | Foreign key cell display |
| Selection modal | Picker dialogs for foreign keys |
| Full record view | Single record page |
| Data entry forms | Both create and edit forms |
| Create form only | New record creation |
| Edit form only | Editing existing records |
| Data export | CSV/JSON export |
| Faceted search | Search sidebar (uses different format) |
Returns: JSON with the updated column list for the context.
Examples: # Add column to end of compact view add_visible_column("Image", "compact", "Description")
# Add foreign key reference at position 1
add_visible_column("Image", "detailed", ["domain", "Image_Subject_fkey"], 1)
# Add pseudo-column
add_visible_column("Image", "compact", {
"source": [{"outbound": ["domain", "Image_Subject_fkey"]}, "Name"],
"markdown_name": "Subject"
})
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| column | Yes | ||
| context | Yes | ||
| position | No | ||
| table_name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |