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

RadDataPager - IsTotalItemCountFixed

5 Answers 267 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Brian Workman
Top achievements
Rank 2
Brian Workman asked on 08 Apr 2010, 01:16 AM
I have a data pager bound to a DomainDataSource that returns an IQueryable<POCO_Obj>.  IsTotalItemCountFixed is set to "True" but it's behaving like infinite paging instead of showing the actual page count and the 'last' arrow button is gray.  Could I be doing something wrong?  2010.1 Current Build

Thanks,
-Brian

5 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 08 Apr 2010, 07:58 AM
Hello Brian Workman,

Could you send us a small sample project that demonstrates this. It can be with some dummy data. We will take a look at it and see what is going on.

Meanwhile, you can try the same with Microsoft's DataPager. Does it behave in the same way or differently?

Thanks in advance.

Best wishes,
Ross
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Brian Workman
Top achievements
Rank 2
answered on 08 Apr 2010, 08:11 PM
I submitted tkt: 298250 and included a simplified test project.

The MS pager does the same thing, but I didn't expect it to work.  I'm probably misunderstanding things, but I thought the Telerik pager could use non-paged sources, autowrapping them in a paged collection, whereas the MS pager could not.

Thanks,
-Brian
0
Rossen Hristov
Telerik team
answered on 09 Apr 2010, 09:54 AM
Hi Brian Workman,

We have examined your project. It appears that the custom implementation of the DomainService is causing both RadDataPager and the MS DataPager to think that there are always more pages. They are confused about the count.

Let me explain what is the difference between non-paged source and paged source. Paged source is something that implements the IPagedCollectionView interface. In your sample project RadDataPager is bound to DomainDataSource.Data which is an IPagedCollectionView. In such cases, RadDataPger simply obeys what this interface is telling it. So you are in a paged source scenario.

A non-paged source is something that is not an IPagedCollectionView, such as an IEnumerable. Your case is not like that. My blog post explains this in great detail.

Since RadDataPager is bound to DomainDataSource.Data it is simply doing what the interface tells it. The custom implementation of the DomainService is not telling it what is the total item count, so the assumption is that it is infinite. That is why both RadDataPager and MS Data Pager have their next/last page buttons always enabled. They think that there is more data on the server.

To make your DomianService tell the pagers the total item count you will have to override its Count method and return the amount of data that is available.

For example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel.DomainServices.Server;
using ClassLibrary1;
  
namespace DataPager_Test.Web.Services
{
    [EnableClientAccess]
    public class TestDomainService : DomainService
    {
        public IQueryable<Class1> getQuery()
        {
            Class1 myClass = new Class1();
            return myClass.getQuery();
        }
  
        protected override int Count<T>(IQueryable<T> query)
        {
            Class1 myClass = new Class1();
            return myClass.getQuery().Count();
        }
    }
}

This will correctly inform anyone that is bound to DomainDataSource.Data, which is an IPagedCollectionView, what is the total amount of data.

If you replace your custom DomainService with a "normal" one, i.e. one created like in tutorials targeting a real DB, then you will see how everything will start working correctly. When you go to the last page you cannot go further. You can see this on our online example Paging Configurator. Experiment with the IsTotalItemCountFixed check-box when you are on the last page. See what will happen.

Once again, I strongly recommend reading my extensive blog post about different paging scenarios. It explains it all.

To learn how to configure your custom Domain Service so that it plays nicely with the rest of the world, please read Nikhil Kothari's blog post. Here is a quote from the comments:

"@Alexandre
For returning total count information we take your query from a query method, compose any incoming query and then perform the equivalent of IQueryable.Count() operation by virtue of calling the Count<T> method on DomainService. You can override Count<T> to customize the counting."

Try this and see how it goes.

We hope that we were able to help. Let us know if you encounter any other problems along the way.

Regards,
Ross
the Telerik team

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 Public Issue Tracking system and vote to affect the priority of the items.
0
Half
Top achievements
Rank 1
answered on 10 May 2011, 08:42 AM
Thanks for the detailed explanation. I would like to narrow the discussion to the scope of my current problem.

Suppose you're consuming a WCF generic Search service that supports server paging by means of two parameters "Page Size" and "Page Number". A separated method, SearchInfo, can be called to retrieve the total number of pages for one particular Search criteria. 
These methods are from an API, thus cannot be modified. Also, it makes it difficult to submit a working example.

What I've done: I have one ObservableCollection Results with the results of Search to which my GridView is bound to.

I have one "dummy" PagedCollectionView created based on SearchInfo. I attached to PageChanged event one method call that calls Search. In other words, when the Page changes, I call Search again, which updates Results and the grid.

Is this the correct approach?
What would be the best approach to implement paging in this scenario?

Thanks 
0
Rossen Hristov
Telerik team
answered on 10 May 2011, 09:09 AM
Hello Half,

Since I am not an authority, I can't really commit to what the most correct approach is.

How would you implement paging if you were using the stock DomainDataSource, the stock DataPager and the stock DataGrid provided by Microsoft?

What I would do is implement the IPagedCollectionView interface, since this gives me the freedom to "fake" page index and page count and trick all controls that respect that interface, in this case the MS DataPager/RadDataPager. In other words, I will be "pulling" my data from the server with the two parameters and then fake the paging through the IPagedCollectionView implementation. Implementing IPagedCollectionView is far from trivial though. For a reference implementation you can reflect Microsoft's PagedCollectionView class. All of this is beyond the scope of Telerik support.

I hope this helps.

Regards,
Ross
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Brian Workman
Top achievements
Rank 2
Answers by
Rossen Hristov
Telerik team
Brian Workman
Top achievements
Rank 2
Half
Top achievements
Rank 1
Share this question
or