Skip to content

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).
  2. 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).
  3. ApplySortPreferences: reads a ;-delimited, ,-separated (column, direction) preference string, splits it, and applies SortIndicator/SortedColumns per column.
  4. On failure: each column application is wrapped in a Try/Catch that silently ignores a missing/renamed column key.
  5. 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.
  6. If Height/Width are both greater than 0: also persists a GRID_SIZE entry.
  7. Calls Preferences.Save() once at the end.
  8. 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.
  9. 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.

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.

Sources

  • SAIF.Presentation.Web.Core.Infragistics103\AppViewPageBase.aspx.vb