---
title: Save / clear grid preferences
summary: Persists or removes a user's saved grid column, sort, and size layout.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Core.Infragistics111
reference_type: package
operation_id: OP-CORE-005
trigger: User action on a consuming page (save layout / reset layout)
---

# Save / clear grid preferences

This operation captures the current grid layout (column order, widths, sort, and size) into the user's preference store, or removes all previously stored preference entries for a grid.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-CORE-005 |
| **Trigger** | User action on a consuming page (save layout / reset layout) |
| **Inputs** | Grid instance, `IncludeSort` flag, optional height/width, `SizeOnly` flag |
| **Outputs** | Persisted or removed preference entries |
| **Primary components** | `AppViewPageBase.SavePreferences`, `AppViewPageBase.ClearPreferences`, `AppViewPageBase.SaveDefaultLayout`, `AppViewPageBase.GetSortPrefs` |
| **Entry point** | `SAIF.Presentation.Web.Core.Infragistics111/AppViewPageBase.aspx.vb` |

## Steps

1. Unless `SizeOnly` is set, iterate every band of the grid and build comma-delimited column-key and column-width lists. ([BR-CORE-014](../business-rules.md#br-core-014-saving-preferences-captures-every-column-of-every-band-as-comma-delimited-key-and-width-lists))
2. `Add` the `ColNames…` and `ColWidths…` entries to the preference store for each band.
3. Evaluate the `IncludeSort` flag.
   - If `True`: build the sort preference string via `GetSortPrefs` from the band's `SortedColumns`.
     - If the built string is non-empty: add `ColSort…` to the preference store. ([BR-CORE-015](../business-rules.md#br-core-015-sort-preferences-are-stored-only-when-the-caller-requests-it-and-a-non-empty-sort-actually-exists))
     - If empty: skip adding the sort entry.
   - If `False`: skip sort preference handling entirely.
4. Evaluate `Height` and `Width`.
   - If both are greater than zero: add `GridSize<gridID>` as `"<height>px,<width>px"`. ([BR-CORE-016](../business-rules.md#br-core-016-grid-size-is-persisted-only-when-both-height-and-width-are-greater-than-zero-in-hpxwpx-form))
   - Otherwise: skip persisting a grid size.
5. Call `Preferences.Save()` to persist all pending changes.
   - > **Origin**: Persistence is delegated to `m_controller.Model.Preferences` (`SAIF.Framework.Preferences`, package `SAIF.BOF.Framework`); the callee's storage mechanism is not visible from this repository.**
6. `ClearPreferences` removes the `ColNames…`, `ColWidths…`, `ColSort…` and `GridSize…` entries and calls `Preferences.Save()`.
   - Note: `Save()` is invoked twice in succession in both the `UltraWebGrid` and `WebDataGrid` overloads (`AppViewPageBase.aspx.vb` lines 426–427 and 707–708) — a redundant call with no functional effect beyond the extra round trip.*

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([User saves or clears layout]) --> Which{Save or Clear?}
	Which -->|Save| S1{SizeOnly?}
	S1 -->|No| S2[Build ColNames/ColWidths per band]
	S1 -->|Yes| S3[Skip column capture]
	S2 --> S4{IncludeSort?}
	S3 --> S4
	S4 -->|Yes, non-empty sort| S5[Add ColSort entry]
	S4 -->|No / empty| S6[Skip sort entry]
	S5 --> S7{Height and Width > 0?}
	S6 --> S7
	S7 -->|Yes| S8[Add GridSize entry]
	S7 -->|No| S9[Skip grid size]
	S8 --> S10[Preferences.Save]
	S9 --> S10
	Which -->|Clear| C1[Remove ColNames/ColWidths/ColSort/GridSize entries]
	C1 --> C2[Preferences.Save called twice]
```

## Failure and edge-case behavior
- `ClearPreferences` calling `Preferences.Save()` twice is a known redundancy, not a functional defect — the second call persists no additional changes.*
- No validation occurs on the supplied `Height`/`Width` beyond the zero-or-greater check.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `SAIF.Presentation.Web.Core.Infragistics111/AppViewPageBase.aspx.vb`
