This is a migrated thread and some comments may be shown as answers.

RadListView Linq and Cache

1 Answer 78 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Glenn
Top achievements
Rank 1
Glenn asked on 08 Jul 2015, 01:36 AM

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" >
            <Items>
                <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" />
            </Items>
        </telerik:RadDropDownList>

<telerik:RadListView ID="RadListView1" runat="server" DataKeyNames="ListingID,GstOptionID" ItemPlaceholderID="ListingsContainer"
       AllowPaging="True"   PageSize="10" AllowMultiFieldSorting="True" CanRetrieveAllData="True">
                  <LayoutTemplate>
                        <asp:Panel ID="ListingsContainer" runat="server" />
                   <table class="pagerTable pagertiles">
               <tr>
                   <td>
                       <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="RadListView1"
                           PageSize="10" Skin="MetroTouch" CssClass="dataPager" >
                           <Fields>
                               <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" />
                               <telerik:RadDataPagerTemplatePageField>
                                   <PagerTemplate>
                                       <div style="float: right">
                                           <b>Items
                                                       <asp:Label runat="server" ID="CurrentPageLabel" Text="<%# Container.Owner.StartRowIndex+1%>" />
                                               to
                                                       <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) %>" />
                                               of
                                                       <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount%>" />
                                               <br />
                                           </b>
                                       </div>
                                   </PagerTemplate>
                               </telerik:RadDataPagerTemplatePageField>
                           </Fields>
                       </telerik:RadDataPager>
                   </td>
               </tr>
                          </table>
       </LayoutTemplate>
       <ItemTemplate>
        ....
       </ItemTemplate>
        
       <EmptyDataTemplate>
      ...
       </EmptyDataTemplate>
   </telerik:RadListView>

 

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
        SaveCacheData(dsTiles)
    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

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 10 Jul 2015, 04:13 PM
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.

Regards,
Angel Petrov
Telerik
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
Tags
ListView
Asked by
Glenn
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or