晨光0703 2009-05-06 00:42
浏览 598
已采纳

Ext 分页后PagingToolbar显示条数的问题。

分页后有这么一条:
[code="java"]displayMsg : '显示第 {0}条到 {1}条记录,一共 {2}条',[/code]
其中的参数{2}是通过ds.data.length来的,还是通过ds里面的:totalProperty来的。

因为现在出现这个问题:ds中的totalProperty为6,但是我分页是3条一页的,
结果出来是这样的:
[code="java"]显示第 1条到 3条记录,一共 3条[/code]

请各位帮忙看看。

[code="java"] var cm = new Ext.grid.ColumnModel([ {
header : "customerId",
width : 120,
dataIndex : 'customerId',
hidden : true
}, {
header : "客户名称",
width : 120,
dataIndex : 'name'
}, {
header : "电子邮件",
width : 200,
dataIndex : 'email',
align : 'right'
}]);

var ds = new Ext.data.Store( {
    proxy : new Ext.data.HttpProxy( {
        url : 'listFollowingCustomerAjax.action'
    }),
    reader : new Ext.data.JsonReader( {
        totalProperty : 'count',
        root : 'values'
    }, [ {
        name : 'customerId'
    }, {
        name : 'name'
    }, {
        name : 'email'
    }])
});

ds.load( {
    params : {
        start : 0,
        limit : 3
    }
});

var grid = new Ext.grid.GridPanel( {
    ds : ds,
    cm : cm,
    id : 'followingCusotmer',
    title : '跟进中客户列表',
    autoHeight : true,
    width : '100%',
    loadMask : true,
    buttons : [ {
        text : '查询',
        tooltip : '客户查询',
        handler : function() {
            alert(ds.data.length);
        }
    }, {
        text : '关闭',
        tooltip : '关闭窗口'
    }],
    buttonAlign : 'right',
    bbar : new Ext.PagingToolbar( {
        id : 'pagingbar',
        pageSize : 3,
        store : ds,
        displayInfo : true,
        displayMsg : '显示第 {0}条到 {1}条记录,一共 {2}条',
        emptyMsg : "没有记录"
    })
});[/code]

[b]问题补充:[/b]
但是在totalProperty中是6,而显示的是3,这是怎么回事呢?

  • 写回答

4条回答 默认 最新

  • zhoujuan520 2009-05-06 08:29
    关注

    [quote]其中的参数{2}是通过ds.data.length来的,还是通过ds里面的:totalProperty来的。 [/quote]

    [code="js"]
    reader : new Ext.data.JsonReader( {

    totalProperty : 'count', //通过这个属性来获得记录总数
    root : 'values'

    }
    [/code]

    下面是源代码
    [code="js"]// private
    updateInfo : function(){
    if(this.displayItem){
    var count = this.store.getCount();
    var msg = count == 0 ?
    this.emptyMsg :
    String.format(
    this.displayMsg,
    this.cursor+1, this.cursor+count, this.store.getTotalCount()
    );
    this.displayItem.setText(msg);
    }
    }[/code]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器