ListView, Paging and SortOrder

15 posts, 0 answers
  1. Michael
    Michael avatar
    1 posts
    Member since:
    Apr 2008

    Posted 08 Feb 2011 Link to this post

    Hello there!

    I'm facing a very strange behaviour.

    I'm using RadListView to display products on our Sitefinity-Website. The RadListView its bound to his data with NeedDataSource. The DataSource itself returns the products in right oder (sorted by name). While displaying the products in RadListView all in one time, it's working fine, but when I set AllowPaging=true, the items are not sorted any more by name. I don't know which field they are sorted by. I don't use any buttons oder code-behind to set a different sort expression and I'm sure that this behaviour is new, since one of the last updates of Sitefinity.

    Version 3.7 SP4 for .NET 4

    Has anyone an idea or has been facing a similar problem?

    Thanks in advance!

    Dieter

  2. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3377 posts
    Member since:
    Sep 2012

    Posted 11 Feb 2011 Link to this post

    Hello Dieter,

    Can you try reproducing the problem in a simple web page outside Sitefinity?
    However, I need to mention that RadListView displayed the records as they are present in its data source. It does not perform any additional actions on its data source internally.

    Let me know how it goes.

    Greetings,
    Iana
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. JM
    JM avatar
    7 posts
    Member since:
    Sep 2006

    Posted 03 Mar 2011 Link to this post

    I'm experiencing the same thing.

  4. Eric
    Eric avatar
    24 posts
    Member since:
    Jan 2008

    Posted 04 Mar 2011 Link to this post

    Hi I am experiencing the same thing.

    I have a RadListView with a RadDataPager and when I set AllowPaging to false and sort the data bound to RadListView manually it works as expected. But when I set AllowPaging to true although the data that I bind to RadLisView is in correct order in ItemDataBound I get the DataItems as if the data is not sorted at all.

    protected void news_NeedDataSource(object sender, Telerik.Web.UI.RadListViewNeedDataSourceEventArgs e)
    {
        NewsManager manager = new NewsManager();
        foreach (SortFieldView view in SortByList)
        {
            if (view.SortDirection != SortDirection.None)
            {
                manager.AddSortField(view.SortField, view.SortDirection);
            }
        }
        var newsList = manager.GetNews();  
       
        List<NewsItem> list = newsList.ToList();
        news.DataSource = list;
    }
     
    protected void news_ItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e)
    {
        if (e.Item.ItemType == Telerik.Web.UI.RadListViewItemType.DataItem ||
           e.Item.ItemType == Telerik.Web.UI.RadListViewItemType.AlternatingItem)
        {
            RadListViewDataItem viewItem = (RadListViewDataItem)e.Item;
            NewsItemControl newsItemControl = (NewsItemControl)e.Item.FindControl("newsItem");
            NewsItem news = (NewsItem)viewItem.DataItem;
     
            newsItemControl.Update(news);
        }
    }

    <telerik:RadListView ID="news" runat="server"
        onitemdatabound="news_ItemDataBound"
        onneeddatasource="news_NeedDataSource" AllowPaging="true">
        <ItemTemplate>
            <uc2:NewsItemControl ID="newsItem" runat="server" />
        </ItemTemplate>
    </telerik:RadListView>
        <telerik:RadDataPager ID="pager" runat="server"
            PagedControlID="news" PageSize="4" EnableEmbeddedSkins="false">
            <Fields>           
                <telerik:RadDataPagerTemplatePageField HorizontalPosition="RightFloat" >
                    <PagerTemplate>
                        <asp:LinkButton Visible="<%# Container.Owner.StartRowIndex == 0 ? false : true %>"
                            ID="btnPrev" runat="server" CommandName="Page" CommandArgument="Prev">< Newer</asp:LinkButton>
                        <asp:LinkButton Visible="<%# Container.Owner.TotalRowCount < Container.Owner.StartRowIndex+Container.Owner.PageSize ? false : true %>"                        
                            ID="btnNext" runat="server" CommandName="Page" CommandArgument="Next">Older ></asp:LinkButton>                   
                    </PagerTemplate>
                </telerik:RadDataPagerTemplatePageField>
                <telerik:RadDataPagerTemplatePageField HorizontalPosition="RightFloat"  >
                    <PagerTemplate>                  
                        <asp:Label runat="server" ID="CurrentPageLabel" Text="<%# Container.Owner.StartRowIndex+1%>" />
                        to
                        <asp:Label runat="server" ID="TotalPagesLabel" Text="<%# Container.Owner.TotalRowCount < Container.Owner.StartRowIndex+Container.Owner.PageSize ?
                        Container.Owner.TotalRowCount : Container.Owner.StartRowIndex+Container.Owner.PageSize %>" />
                        of
                        <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount%>" />
                        <br />
                    </PagerTemplate>
                </telerik:RadDataPagerTemplatePageField>
            </Fields>
        </telerik:RadDataPager>

    Thank you...

  5. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3377 posts
    Member since:
    Sep 2012

    Posted 07 Mar 2011 Link to this post

    Hello,

    Is the issue you are facing available in a simple web site? Can you share it or some code where we can observe the problem?

    Kind regards,
    Iana
    the Telerik team

    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

  6. Eric
    Eric avatar
    24 posts
    Member since:
    Jan 2008

    Posted 07 Mar 2011 Link to this post

    Hi Iana,

    The problem occurs if I use ADO.NET Entity Model as a data source, if I use regular classes and Lists it doesn't happen.

    I attached a sample solution to my support ticket named "Sorting Problem with AllowPaging enabled".

    Thank you...

  7. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3377 posts
    Member since:
    Sep 2012

    Posted 07 Mar 2011 Link to this post

    Hi Eric,

    I will check the sample you provided and turn back to you with my findings.
    In the meanwhile, can you try the same scenario with ASP:ListView so we can further isolate the issue?

    Best wishes,
    Iana
    the Telerik team

    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

  8. Eric
    Eric avatar
    24 posts
    Member since:
    Jan 2008

    Posted 07 Mar 2011 Link to this post

    It works with ASP:ListView.

    Note: In order to make ASP:ListView paging work with RadDataPager I had to convert the data source to a list by using ToList() method of IQueryable<T>. I also did the same in the RadListView need data source but it didn't work for RadListView.

    Thank you...

  9. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3377 posts
    Member since:
    Sep 2012

    Posted 08 Mar 2011 Link to this post

    Hi Eric,

    I tested the project provided in the support thread and here are my findings:

    After further debugging it appeared the issue is due to a limitation in the Entity Framework. In order allow paging, e.g. to be able to call the Skip() and Take() methods, the list of records should be sorted. Therefore the RadListView is sorting the data source is sorted by the first data field. However I have forwarded the issue to our developers and they will change the listview behavior so sorting will work with page if the sorting is performed through the listview API, i.e. is sort expressions are added to it. In this case the sorting will be still performed at database level but the listview will pass the sort expressions to it for you.

    Regards,
    Iana
    the Telerik team

    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

  10. James B.
    James B. avatar
    24 posts
    Member since:
    Jan 2011

    Posted 10 Mar 2011 Link to this post

    Thought I'd mention I just found out about this issue today as well.

    This is a normal asp.net site where we upgraded the telerik components recently. I've done built in paging with a radlistview with older versions of telerik that work just fine. So guessing this is a recent issue.

  11. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3377 posts
    Member since:
    Sep 2012

    Posted 14 Mar 2011 Link to this post

    Hi James,

    Thank you for sharing your finding with us and with the community. We will take them into account in performing further investigation and addressing the issue.

    Greetings,
    Iana
    the Telerik team

    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

  12. Tom
    Tom avatar
    1 posts
    Member since:
    Jun 2012

    Posted 27 Jun 2012 Link to this post

    Hello,

    I have just encountered this problem too. Do you know if it is now fixed? or is there a workaround i can use?

  13. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3377 posts
    Member since:
    Sep 2012

    Posted 28 Jun 2012 Link to this post

    Hello,

    The issue is already fixed. If you are using the latest version you should not experience the behavior discussed in this thread.

    Regards,
    Iana Tsolova
    the Telerik team

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.

  14. Colin Wright
    Colin Wright avatar
    25 posts
    Member since:
    Mar 2008

    Posted 01 Dec in reply to Iana Tsolova Link to this post

    I am experiencing this issue and I am using the very latest version of Telerik Controls

  15. Angel Petrov
    Admin
    Angel Petrov avatar
    792 posts
    Member since:
    Dec 2014

    Posted 04 Dec Link to this post

    Hi Colin,

    I have already provided an answer in the official support ticket you have opened regarding this matter. As soon as we finish investigating the problem you can share your findings here thus helping other community members overwhelm such type of problems.

    Regards,
    Angel Petrov
    Telerik

     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     

Back to Top