Layout persistence
ArionUI.Layout · free during the preview, also commerciallyThe state a user builds up — column widths, order and visibility, sorting, grouping, filters, summaries, conditional rules, frozen columns, zoom — captured as one object, written as JSON, and applied again on the next start.
Install
dotnet add package ArionUI.Layout --prereleaseThe package brings ArionUI.Formatting and ArionUI.Planning along, whose state a layout can carry. Capturing or applying a layout switches the module on.
Capture and apply
ArionLayout layout = grid.Api.CaptureLayout(view); // columns, sorting, grouping, filters, rules ...
string json = ArionLayoutSerializer.ToJson(layout);
// next start:
if (ArionLayoutSerializer.FromJson(json) is { } saved)
{
grid.Api.ApplyLayout(view, saved);
}Layouts name columns by key, never by position — otherwise a saved state would point at the wrong column after the user moved one. Every column needs a key from .WithKey(…), and capturing a layout throws for a column without one. Applying is tolerant: an unknown key or a missing part is skipped. A layout of a different format version is not: ApplyLayout throws NotSupportedException, and there is deliberately no migration while the preview has no installed base. Treat it as "start fresh"; GridLayoutFile.TryLoad below does exactly that.
A layout carries no theme. The theme is the application's choice, not part of what the user arranged; persist it yourself if users pick one.
Choosing what to keep
var columnsOnly = grid.Api.CaptureLayout(view, ArionLayoutParts.Columns | ArionLayoutParts.Sorting);ArionLayoutParts is a set of flags: Columns, Sorting, Grouping, Filters, Summaries, ConditionalRules, FrozenColumns, View, or All (the default).
To a file
GridLayoutFile.TryLoad(path, saved => grid.Api.ApplyLayout(view, saved), Log);
// when the window closes:
GridLayoutFile.TrySave(path, () => grid.Api.CaptureLayout(view), Log);A missing or unreadable file is not an error: a remembered layout is a convenience, and losing it must not stop the window from opening. Failures — including a layout of another version — are passed to the log callback and never thrown, because saving usually runs while the window is closing.
For a planning matrix, ArionLayout.Planning has room for its date range, bucket and visible measures as a PlanningLayout. CaptureLayout does not fill it — set it from PlanningLayout.Capture(axis, measures) before saving, and rebuild the axis from it after loading; see Planning matrix. Below the grid level, view.CaptureLayout() and view.ApplyLayout(layout) work on a view alone, without frozen columns and zoom.
