---
title: Grid column/sort/size preference persistence
summary: Applies, saves, and clears per-user grid layout preferences for UltraWebGrid and WebDataGrid controls.
status: draft
owner: SAIF Documentation Team
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Core.Infragistics103
reference_type: package
operation_id: OP-AVPB-002
trigger: Called explicitly by consuming page code around grid data-bind/postback
---

# Grid column/sort/size preference persistence

This operation applies, saves, and clears a user's persisted grid layout preferences (column order/width, sort order, size) for both `UltraWebGrid` and `WebDataGrid` controls, backed by `SAIF.Framework.Preferences`.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-AVPB-002 |
| **Trigger** | Called explicitly by consuming page code around grid data-bind/postback |
| **Inputs** | Grid instance, optional size div |
| **Outputs** | Grid layout applied/persisted, or an ORDER BY-style string |
| **Primary components** | `AppViewPageBase.ApplyColumnPreferences`, `ApplySortPreferences`, `GetSortPreferenceOrderBy`, `SavePreferences`, `ClearPreferences` (each overloaded for `UltraWebGrid` and `WebDataGrid`) |
| **Entry point** | `SAIF.Presentation.Web.Core.Infragistics103\AppViewPageBase.aspx.vb` |

## Steps

1. `ApplyColumnPreferences`: for each grid band, first calls `SaveDefaultLayout` (captures the grid's as-designed column order/width/size into `ViewData`, to allow later reset).
   - Then reads `COLUMN_NAMES`/`COLUMN_WIDTHS`/`GRID_SIZE` values from `m_controller.Model.Preferences` (keyed by grid ID + band key) and applies them via `ApplyColSettings` (column reordering via `Move`, width via `Unit`, and div size for the first band only).
2. `ApplySortPreferences`: reads a `;`-delimited, `,`-separated (column, direction) preference string, splits it, and applies `SortIndicator`/`SortedColumns` per column.
   - On failure: each column application is wrapped in a `Try/Catch` that silently ignores a missing/renamed column key.
3. `SavePreferences`: clears all page-level preferences (`Preferences.Clear(PrefScope.PageLevel)`), then re-derives column name/width/sort strings from the grid's current live state and re-adds them.
   - If `Height`/`Width` are both greater than 0: also persists a `GRID_SIZE` entry.
   - Calls `Preferences.Save()` once at the end.
4. `ClearPreferences`: removes all four preference keys for the grid, saves twice (redundant), then calls `ApplyDefaultLayout` to restore the pre-preference layout captured by the last `SaveDefaultLayout` call.
5. The `WebDataGrid` overloads follow the same structural steps against `Infragistics.Web.UI.GridControls.WebDataGrid`/`Behaviors.Sorting`/`Behaviors.EditingCore` APIs instead of `UltraWebGrid.DisplayLayout.Bands`.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Grid data-bind/postback]) --> S1[SaveDefaultLayout captures as-designed layout]
	S1 --> S2[ApplyColumnPreferences reads and applies COLUMN_NAMES/WIDTHS]
	S2 --> S3[ApplySortPreferences reads and applies sort string]
	S3 --> D1{Column key missing/renamed?}
	D1 -->|Yes| Skip[Silently skip that column]
	D1 -->|No| Applied[Sort applied]
	Applied --> S4[User interacts, SavePreferences on postback]
	S4 --> S5[Clear + re-derive + Save preferences]
	S5 --> EndOk([Preferences persisted])
```

## Failure and edge-case behavior
- `ApplySortPreferences` silently ignores a missing/renamed column key via `Try/Catch`.
- `ClearPreferences` calls `Preferences.Save()` twice, which is redundant but not harmful.

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

## Sources
- SAIF.Presentation.Web.Core.Infragistics103\AppViewPageBase.aspx.vb
