Principle:AFK surf Open agent View GroupBy Configuration
| Knowledge Sources | |
|---|---|
| Domains | Database, Data_View, BlockSuite |
| Last Updated | 2026-10-25 00:00 GMT |
Overview
Pattern of grouping rows by a chosen property column, scoped per view, by writing a groupBy setting derived from the column's property meta via the view's GroupTrait.
Description
Group-by organizes rows into buckets keyed by a property's value (e.g. group cards by a multi-select tag). It is view-scoped: each view (table, kanban) can group by a different column. The GroupTrait is retrieved from the current view via traitGet(groupTraitKey). Calling changeGroup(columnId) resolves the column, looks up its property meta from the data source, computes a defaultGroupBy (carrying the column id, type, and a default grouping strategy), and writes it via ops.groupBySet. Passing undefined clears the grouping. The kanban view renders groups using this configuration.
Usage
Apply this principle when you want to organize rows into groups within a view — kanban cards grouped by status, table rows grouped by a tag — while keeping other views ungrouped or grouped differently.
Theoretical Basis
Group-by is a view-scoped partition: groupBy: GroupBy = { columnId, type, ... }. The GroupTrait maps the column's TypeInstance to a GroupByConfig via the group-by matcher service, which provides defaultKeys and grouping operations (addTo, removeFromGroup). Writing the groupBy re-derives the group list reactively.
Pseudo-code:
const groupTrait = viewManager.currentView$.value?.traitGet(groupTraitKey);
groupTrait?.changeGroup(database.props.columns[1].id);