Listview inside a dock paging causes dockstorage updates

2 posts, 0 answers
  1. Punit
    Punit avatar
    9 posts
    Member since:
    Dec 2014

    Posted 30 Dec 2015 Link to this post

    I have a bunch of different docks containing a listviews on a page.  See example below.   We are using custom docklayout storage -see below.  My question is why is LoadStateFromStorage called before a paging event and then SaveStateToStorage is called after it.  So whenever a user pages, there are 3 calls to the database.


    Public Class DockLayoutStorage
    Implements IStateStorageProvider
    Public Function LoadStateFromStorage(key As String) As String Implements IStateStorageProvider.LoadStateFromStorage
    Dim params As List(Of SqlParameter)
    params = New List(Of SqlParameter)
    params.Add(New SqlParameter("@User_Id", key))
    Return OGC.Toolkit.Misc.DataAccess.ExecuteScalar("GetDockState", params, "csxxxx").ToString
    End Function
    Public Sub SaveStateToStorage(key As String, serializedState As String) Implements IStateStorageProvider.SaveStateToStorage
    Dim params As List(Of SqlParameter)
    params = New List(Of SqlParameter)
    params.Add(New SqlParameter("@User_Id", key))
    params.Add(New SqlParameter("@Dock_State", serializedState))
    OGC.Toolkit.Misc.DataAccess.ExecuteQuery("InsUpdDockStates", params, "csxxx")
    End Sub


    <telerik:RadDock runat="server" ID="dockNotifications" Title="Notifications" Style="margin-bottom: 5px; margin-top: 5px" DefaultCommands="ExpandCollapse" EnableAnimation="true"
    AutoPostBack="true" DockMode="Docked" CommandsAutoPostBack="true" EnableRoundedCorners="true">
    <telerik:RadAjaxPanel ID="upNotifications" runat="server" LoadingPanelID="uprgNotifications">
    <asp:ListView runat="server" ID="lvNotifications" DataSourceID="odsNotifications">
    <asp:PlaceHolder runat="server" ID="itemPlaceHolder"></asp:PlaceHolder>
    <telerik:RadDataPager ID="dpNotifications" runat="server" PagedControlID="lvNotifications" PageSize="5" Skin="Default" OnCommand="dp_Command">
    <telerik:RadDataPagerButtonField FieldType="FirstPrev"></telerik:RadDataPagerButtonField>
    <telerik:RadDataPagerButtonField FieldType="Numeric"></telerik:RadDataPagerButtonField>
    <telerik:RadDataPagerButtonField FieldType="NextLast"></telerik:RadDataPagerButtonField>
    <telerik:RadDataPagerPageSizeField PageSizeText="Page size: " PageSizes="5,10,20,50" HorizontalPosition="RightFloat" PageSizeControlType="RadDropDownList"></telerik:RadDataPagerPageSizeField>
    <fieldset class="dock">
    <legend style="font-weight: bold"><%#Eval("Notification_Header")%></legend>
    <asp:Literal runat="server" ID="litNotificationText"></asp:Literal>
    <div class="center" style="margin-top: 5px">No notifications available.</div>
    <asp:ObjectDataSource ID="odsNotifications" runat="server" TypeName="xxx.DataAccess" SelectMethod="GetDataTable">
    <asp:Parameter Name="sProc" DefaultValue="xxxGetNotifications" />
    <asp:Parameter Name="params" />
    <asp:Parameter Name="connStr" DefaultValue="csxxx />
    <telerik:RadAjaxLoadingPanel ID="uprgNotifications" runat="server" Skin="Default" MinDisplayTime="0"></telerik:RadAjaxLoadingPanel>



  2. Slav
    Slav avatar
    1351 posts

    Posted 04 Jan Link to this post

    Hi Punit,

    The LoadStateFromStorage and SaveStateToStorage methods are called respectively by the handlers of the LoadDockLayout and SaveDockLayout server-side events of RadDockLayout. These two events are raised in the proper moments for loading and saving the dock state, which is shown in the following schema:

    This means that the mentioned methods need to be called in the moments you noticed in order for the persistence of the dock state to work. If calling the database two additional times for loading and saving the dock state is an issue, you can store the dock state in another storage of your choosing. You can then synchronize the data stored in the chosen storage with the database when you call it for loading the data in the listviews.

    The downside of this approach is that the database will not have the latest state of the RadDock controls, because the saving on the database will occur before the dock state is retrieved during the SaveDockLayout event on each page load.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
Back to Top