Datapager不显示总页数 [英] Datapager does not showing total page count

查看:87
本文介绍了Datapager不显示总页数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我已经在Silverlight Business Application中创建了自定义域服务类,并且在其中创建了一个返回IQueryable< myClass>的方法.此方法获取List< myClass> (在WCF服务中声明myClass),然后从WCF Servce中将其返回为AsQueryable().
这是代码:

Hello to everybody
I have created custom domain service class in Silverlight Business Application and one method in it that returns IQueryable<myClass>. This method gets List<myClass> (myClass is declared in WCF Service) from WCF Servce and returns it AsQueryable().
Here is the code:

[EnableClientAccess()]
    public class myDomainService : DomainService
    {
        public IQueryable<myClass> GetMatchedmyClasses(string mathingData)
        {
            myServiceClient proxy = new myServiceClient();
            List<myClass> lst = proxy.GetmyClassList(mathingData);

            return lst.AsQueryable().OrderBy(e => e.Id);
        }
    }


当我将此方法(位于生成的代码文件中)与DomainDataSource一起使用并将其绑定到DataGrid时,一切正常,但是当我将DataPager绑定到DomainDataSource或DataGrid时,当行数大于DomainDataSource的LoadSize属性.例如,如果DomainDataSources LoadSize ="20"且返回的列表计数为100,则无法显示总行数,但是如果列表计数小于15,则其将显示总行数,具体取决于所用DataPager的PageSize属性. 即使我创建List< myClass> ;,该问题仍然存在.在域服务类中,而不是从WCF中获取它.我想我必须使用List<>以外的其他东西,该集合将可用于将行和页面的总数转移到Silverlight业务应用程序的客户端


When I use this method (that is located in generated code file) with DomainDataSource and bind it to DataGrid everything is ok, but when I bind DataPager to DomainDataSource or DataGrid, it’s unable to display total page size when the number of rows is more than LoadSize property of DomainDataSource. For example if DomainDataSources LoadSize="20" and returned list count is 100 it can not show total rows, but if list count is less than 15 then it shows total rows count depending on PageSize property of used DataPager.
This problem remains even if I create List<myClass> in domain service class instead of getting it from WCF. As I guess I must use something other than List<>, a collection that will be available to transfer the total count of rows and pages to the client side of Silverlight business application

Any help will be highly appreciated

推荐答案

该控件正在分页给出的数据,并且通过请求返回最大记录数来减少服务器负载.解决此问题的最佳方法是编写一个方法,该方法还返回记录总数,然后使用该数字显示分页控件.最后,我看了一下,这意味着编写自定义分页,因为内置控件假定为它们提供了所有数据.您可以使用未列出页面的空白记录填充列表,但这有点讨厌.
The control is paging the data it is given, and you''re reducing server load by requesting a maximum number of records to return. The best way around this, is to write a method which also returns the total number of records, then use that number to show your paging control. Last I looked, that meant writing custom paging, because the built in controls assume they are given all the data. You COULD pad your list with empty records for the pages not shown, but that''s a bit of a nasty hack.


谢谢克里斯蒂安的回答.
我解决了这个问题,并且有一种非常简单的方法可以做到这一点.我只需要覆盖Count< t> DomainService类的方法.看起来像这样:

Thank you for your answer Christian.
I solved this problem and there is very easy way to do that. I just need to override Count<t> method of DomainService class. it''s looks like this:

protected override int Count<T>(IQueryable<T> query)
{
    return query.Count<T>();
}


这篇关于Datapager不显示总页数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆