RadListView Linq and Cache

2 posts, 0 answers
  1. Glenn
    Glenn avatar
    47 posts
    Member since:
    Nov 2011

    Posted 07 Jul 2015 Link to this post

    I am trying to keep the latency to a minimum when using a Radlistview which grabs it's data from sql with linq. Example of how data is currently retrieved is as follows:-

    <telerik:RadDropDownList ID="RadDropDownListSort" runat="server" Skin="MetroTouch" CssClass="sortCtrl" DefaultMessage="Sort by..." Width="175px" AutoPostBack="False" OnClientItemSelecting="sortSelecting" >
                    <telerik:DropDownListItem Text="Sort by Price" Value="SalePrice" />
                       <telerik:DropDownListItem Text="Sort by Year" Value="YearOfMan" />
                    <telerik:DropDownListItem Text="Sort by Location" Value="Location" />
                    <telerik:DropDownListItem Text="Sort by Make/Model" Value="Make" />
                    <telerik:DropDownListItem Text="Sort by Category" Value="Category" />

    <telerik:RadListView ID="RadListView1" runat="server" DataKeyNames="ListingID,GstOptionID" ItemPlaceholderID="ListingsContainer"
           AllowPaging="True"   PageSize="10" AllowMultiFieldSorting="True" CanRetrieveAllData="True">
                            <asp:Panel ID="ListingsContainer" runat="server" />
                       <table class="pagerTable pagertiles">
                           <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="RadListView1"
                               PageSize="10" Skin="MetroTouch" CssClass="dataPager" >
                                   <telerik:RadDataPagerButtonField FieldType="FirstPrev" />
                                   <telerik:RadDataPagerButtonField FieldType="Numeric" />
                                   <telerik:RadDataPagerButtonField FieldType="NextLast" />
                                   <telerik:RadDataPagerPageSizeField PageSizeText="Tiles per page: " PageSizeComboWidth="62" PageSizes="20 30" />
                                   <telerik:RadDataPagerGoToPageField CurrentPageText="Page: " TotalPageText="of" SubmitButtonText="Go"
                                       TextBoxWidth="20" />
                                           <div style="float: right">
                                                           <asp:Label runat="server" ID="CurrentPageLabel" Text="<%# Container.Owner.StartRowIndex+1%>" />
                                                           <asp:Label runat="server" ID="TotalPagesLabel" Text="<%# IIF(Container.Owner.TotalRowCount > (Container.Owner.StartRowIndex+Container.Owner.PageSize), Container.Owner.StartRowIndex+Container.Owner.PageSize, Container.Owner.TotalRowCount) %>" />
                                                           <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount%>" />
                                                   <br />


    Private Sub RadListView1_NeedDataSource(sender As Object, e As Telerik.Web.UI.RadListViewNeedDataSourceEventArgs) Handles RadListView1.NeedDataSource
        Dim dsTiles As IQueryable(Of ListingResults) = GetLinqListingData
        RadListView1.DataSource = dsTiles
    End Sub

    Having looked through the documentation and demos for the RadListview, I'm struggling to understand what amount of data is retrieved from sql and/or the server when the page first loads and on subsequent page change or sort on ajax call back.  When using Iqueryable does the Radlistview grab only the data for the page shown to the user?  IE 10 rows for page size of 10 retrieved from sql OR perhaps: All rows retrieved to server, but only 10 rows sent to client (user).

    Presuming that it only grabs the rows for displayed items on the page, if I try to implement the usage of a shared (and/or local) cache as follows, the full set of rows would need to be retrieved from sql for first save to the cache. And on each and every page change or sort, the full set of rows is again retrieved from the cache.  A suggested example of using cache:

    Private Sub RadListView1_NeedDataSource(sender As Object, e As Telerik.Web.UI.RadListViewNeedDataSourceEventArgs) Handles RadListView1.NeedDataSource
        Dim dsTiles As List(Of ListingResults) = GetCacheData
        If dsTiles is nothing
            dsTiles = GetLinqListingData
        End If
        RadListView1.DataSource = dsTiles
    End Sub


    Would greatly appreciate any explanation on how data is retrieved and any suggestion of whether cache is beneficial for short-term single user usage and longer term subsequent visitors seeking the same data.

    Thank you

  2. Angel Petrov
    Angel Petrov avatar
    1076 posts

    Posted 10 Jul 2015 Link to this post

    Hello Glenn,

    When the control loads and paging is enabled it will obtain the entire set of data from the database and later will page them and display a concrete subset of data. That said integration an optimization such as storing the data source in the cache or in the Session is a good idea. By following this approach you should be able to optimize the performance.

    Angel Petrov
    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
Back to Top