State Persistence in ASP.NET Core

22 Apr 20221 minute to read

The Syncfusion ASP.NET Core library supports persisting a control’s state across page refreshes or navigation. To enable this feature, set enablePersistence property as true to the required control. This will store the control’s state in browser’s localStorage object on page unload event.

<ejs-grid id="Grid" enablePersistence="true" allowPaging="true">
    <e-grid-pageSettings pageCount="5"></e-grid-pageSettings>                  
    <e-data-manager url='https://services.odata.org/V4/Northwind/Northwind.svc/Products/' adaptor="ODataV4Adaptor"  crossdomain="true"></e-data-manager>
    <e-grid-columns>
        <e-grid-column field="ProductID" headerText="ProductID" textAlign="Right" width="160"></e-grid-column>
        <e-grid-column field="ProductName" headerText="Product Name" width="170"></e-grid-column>
        <e-grid-column field="UnitPrice"  headerText="Unit Price" format="C2" textAlign="Right" width="170"></e-grid-column>
        <e-grid-column field="UnitsInStock" headerText="Units in Stock" textAlign="Right" width="170"></e-grid-column>
        <e-grid-column field="Discontinued" headerText="Discontinued" width="150" displayAsCheckBox="true"  textAlign="Center" type="boolean"></e-grid-column>
    </e-grid-columns>
</ejs-grid>

State Persistence Supported controls and Properties

The following table demonstrates the list of Syncfusion ASP.NET Core controls that are supported with state persistence and describes the list of properties stored in the localStorage.

control Name Properties
Grid
  • Columns
  • filterSettings
  • searchSettings
  • groupSettings
  • pageSettings
  • selectedRowIndex
  • scrollPosition
Accordion
  • expandedIndices
Tabs
  • selectedItem
Schedule
  • currentView
  • selectedDate
  • scrollLeft
  • scrollTop
Kanban
  • columns
  • dataSource
  • swimlaneToggleArray
Chart
  • zoomFactor
  • zoomPosition
Maps
  • zoomSettings
Pivot Table
  • dataSourceSettings
  • pivotValues
  • gridSettings
  • chartSettings
  • displayOption
TreeGrid
  • columns
  • pageSettings
  • searchSettings
  • filterSettings
  • selectedRowIndex
  • sortSettings
Switch
  • checked
Checkbox
  • checked
RadioButton
  • checked
  • value
ColorPicker
  • value
ListBox
  • value
QueryBuilder
  • rule
In-placeEditor
  • value
RichTextEditor
  • value
Splitter
  • paneSettings
Autocomplete
  • value
Calendar
  • value
ComboBox
  • value
DatePicker
  • value
DropDownList
  • value
MaskedTextBox
  • value
NumericTextBox
  • value
Textbox
  • value
TimePicker
  • value
Multiselect
  • value
DateTimePicker
  • value
DateRangePicker
  • startDate
  • endDate
  • value
Uploader
  • filesData
Slider
  • value
ListView
  • cssClass
  • enableRtl
  • htmlAttributes
  • enable
  • fields
  • animation
  • headerTitle
  • sortOrder
  • showIcon
  • height
  • width
  • showCheckBox
  • checkBoxPosition
TreeView
  • selectedNodes
  • checkedNodes
  • expandedNodes
Dashboard Layout
  • panels
File Manager
  • view
  • path
  • selectedItems
Sidebar
  • type
  • position
  • isOpen
Dropdown Tree
  • value