使用WCF服务在Extjs中进行分页

时间:2012-08-24 12:08:24

标签: .net wcf extjs

我的URI(WCF服务)中存在put grid的分页参数问题。

这是我网格的“商店”代码:

Ext.define('KP.store.Listls', {

    extend: 'Ext.data.Store',
    model: 'KP.model.Listls',

    autoLoad: true,

    pageSize: 50,
    autoLoad: { start: 0, limit: 50 },


    autoSync: true,
    proxy: {
        type: 'ajax',           
        startParam: undefined,
        api: {

        read: '/adres/listls?page=' + 1  + '&size=' + 20            
        },
        reader: {
            type: 'json',
            root: 'data',           
            totalProperty: 'total'
        }     
    }

});

这是我的界面服务代码:

 [WebInvoke(
        Method = "GET",
        //UriTemplate = "/list",
        UriTemplate = "listls?page={page}&size={size}",                
        RequestFormat = WebMessageFormat.Json,
        ResponseFormat = WebMessageFormat.Json,
        BodyStyle = WebMessageBodyStyle.Bare
    )]
    List<Person> GetLs(string page, string size);

问题在于此代码字符串:

read: '/adres/listls?page=' + ???  + '&size=' + 20

我将使用什么样的参数来理解页码? 非常感谢!

1 个答案:

答案 0 :(得分:1)

这不是那么容易,但它是可行的。您需要实现两件事:

  1. 将ExtJs阅读器的$skip改为startParam,将$take改为limitParam。而且您不需要在WCF端实现任何特殊逻辑来解析它。它已经了解$skip$take

  2. 更改WCF端以某种方式发送记录总数。因为默认情况下使用分页时,JSON对象内发送的记录总数将为-1。

相关问题