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

ListView, Paging and SortOrder

14 Answers 136 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 08 Feb 2011, 03:35 PM
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

14 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 11 Feb 2011, 10:47 AM
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.
0
JM
Top achievements
Rank 1
answered on 03 Mar 2011, 02:31 PM
I'm experiencing the same thing.
0
Eric
Top achievements
Rank 1
answered on 04 Mar 2011, 07:53 PM
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...

0
Iana Tsolova
Telerik team
answered on 07 Mar 2011, 01:12 PM
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!
0
Eric
Top achievements
Rank 1
answered on 07 Mar 2011, 04:47 PM
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...
0
Iana Tsolova
Telerik team
answered on 07 Mar 2011, 04:51 PM
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!
0
Eric
Top achievements
Rank 1
answered on 07 Mar 2011, 05:23 PM
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...
0
Iana Tsolova
Telerik team
answered on 08 Mar 2011, 05:15 PM
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!
0
James B.
Top achievements
Rank 1
answered on 10 Mar 2011, 10:25 PM
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.
0
Iana Tsolova
Telerik team
answered on 14 Mar 2011, 10:50 AM
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!
0
Tom
Top achievements
Rank 1
answered on 27 Jun 2012, 10:32 AM
Hello,

I have just encountered this problem too. Do you know if it is now fixed? or is there a workaround i can use?
0
Iana Tsolova
Telerik team
answered on 28 Jun 2012, 08:52 AM
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.
0
Colin Wright
Top achievements
Rank 1
answered on 01 Dec 2014, 02:51 PM
I am experiencing this issue and I am using the very latest version of Telerik Controls
0
Angel Petrov
Telerik team
answered on 04 Dec 2014, 09:42 AM
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.

 
Tags
ListView
Asked by
Michael
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
JM
Top achievements
Rank 1
Eric
Top achievements
Rank 1
James B.
Top achievements
Rank 1
Tom
Top achievements
Rank 1
Colin Wright
Top achievements
Rank 1
Angel Petrov
Telerik team
Share this question
or