---
title: Apply saved grid preferences
summary: Re-applies a user's saved column order, widths, sort, and size layout to a grid.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-08-17
library: SAIF.Presentation.Web.Core.Infragistics111
reference_type: package
operation_id: OP-CORE-004
trigger: Called by a consuming page while rendering a grid
---

# Apply saved grid preferences

This operation restores a signed-in user's previously saved grid layout — column order, column widths, sort order, and overall grid size — for either an `UltraWebGrid` or a `WebDataGrid`, keyed per grid and per band.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-CORE-004 |
| **Trigger** | Called by a consuming page while rendering a grid |
| **Inputs** | Grid instance, optional size `div`, the user's preference store (`m_controller.Model.Preferences`) |
| **Outputs** | Reordered/resized grid columns, applied sort criteria, applied grid height/width |
| **Primary components** | `AppViewPageBase.ApplyColumnPreferences`, `AppViewPageBase.ApplySortPreferences`, `AppViewPageBase.ApplyColSettings`, `AppViewPageBase.ApplyDefaultLayout` |
| **Entry point** | `SAIF.Presentation.Web.Core.Infragistics111/AppViewPageBase.aspx.vb` |

## Steps

1. Compute the band key for the grid band (`GetBandKey`) so multi-band `UltraWebGrid` layouts store preferences separately from single-band grids. ([BR-CORE-011](../business-rules.md#br-core-011-grid-layout-preferences-are-keyed-by-preference-type-grid-id-band-key))
2. Read `ColNames<gridID><bandKey>`, `ColWidths<gridID><bandKey>` and `GridSize<gridID>` from the preference store.
   - If an entry is missing: treat it as "no preference" for that dimension and skip applying it.
   - > **Origin**: Preference retrieval delegates to `m_controller.Model.Preferences` (`SAIF.Framework.Preferences`, package `SAIF.BOF.Framework`). The callee's own storage/lookup steps are not visible from this repository.**
3. Apply the stored column order and widths to the grid band, then apply the stored grid height/width to the grid (and to the containing size `div` when supplied). ([BR-CORE-012](../business-rules.md#br-core-012-stored-column-order-widths-and-grid-size-are-re-applied-when-the-grid-renders))
4. Read `ColSort<gridID><bandKey>` and re-apply the stored sort direction per column. ([BR-CORE-013](../business-rules.md#br-core-013-stored-sort-preferences-are-re-applied-and-can-be-converted-into-an-order-by-fragment-for-the-callers-query))
5. `GetSortPreferenceOrderBy` converts the stored sort preference into an `ORDER BY` fragment.
   - The caller is responsible for appending this fragment to its own data retrieval query. This library builds the fragment only; it issues no SQL of its own.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Grid rendering begins]) --> S1[Compute band key]
	S1 --> S2[Read ColNames/ColWidths/GridSize from Preferences]
	S2 --> Found{Preference entry present?}
	Found -->|No| Skip([Skip that dimension])
	Found -->|Yes| S3[Apply column order, widths, grid size]
	S3 --> S4[Read ColSort and re-apply sort]
	S4 --> S5[GetSortPreferenceOrderBy builds ORDER BY fragment]
	S5 --> EndOk([Caller appends fragment to its own query])
```

## Failure and edge-case behavior
- Missing preference entries never raise — the corresponding layout dimension simply reverts to the grid's design-time default.
- No SQL is executed by this operation; `GetSortPreferenceOrderBy` returns a fragment string that the caller must incorporate safely into its own parameterized query.*

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

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