Data Model
GridModel
GridModel holds everything about the grid's data and layout:
Creating a model
In-memory data
This wraps the Vec<RowRecord> in a VecDataSource internally.
Custom data source
Patches layer
Edited cell values are stored in patches — a HashMap<(u64, String), String>
mapping (row_index, col_key) to the new value. Patches override the underlying
data source, which means editing works even with read-only sources like
FnDataSource.
DataSourceMode
In ServerSide mode, apply_sort() and apply_filter() become no-ops —
the server is responsible for returning already-sorted/filtered data.
Logical-to-physical row mapping
When sorting or filtering is active, the display order differs from the data source order:
model.logical_to_physical(logical_row) resolves this mapping:
- If
filtered_indicesis non-empty → use it (already in sort order) - Else if
sort_orderis non-empty → use it - Else → identity (logical == physical)
Row number gutter
The row number gutter width is auto-computed based on the digit count of the largest row number:
This ensures the gutter is always wide enough to display all row numbers without truncation.