The View object
defaultView(schema) builds the starting view from the schema: column widths, flex, pins and hidden columns from the column options, and a footer entry for every column with an aggregate.
The view store
Every grid owns a view store atgrid.view. It holds the current view, and every change goes through it.
view-store.ts
Sort direction
toggleSort starts a column at its natural direction: descending for numbers and dates, ascending for everything else. A second toggle flips it, and a third removes it. With additive set, the column is added to the existing sorts instead of replacing them.
Reconciling with the schema
A saved view can outlive the schema it was saved against.set and createViewStore reconcile every view: unknown columns are dropped, new columns are inserted next to their neighbours in the schema, and sorts, groups, rules and footer entries for missing columns are removed. A footer aggregate the column type does not support is removed too.
validateView(input) checks an untrusted object, such as one read from storage, and throws invalid_view with one detail per problem.
Reloading
The grid reloads when the filter, the sort, the group or the footer changes, and goes back to the first page. Layout changes such as widths, order and density do not reload.Views in the URL
viewToUrlString and viewFromUrlString write a view to a query string and read it back.
url.ts
q. The rest is written only when it differs from the default view:
Other parameters are left alone. Pass
param to use another name than q. In React, useViewUrl(grid) keeps the view and the URL in sync.