【问题标题】:Sencha Touch ListPaging TotalCount not being setSencha Touch ListPaging TotalCount 未设置
【发布时间】:2014-06-18 17:13:33
【问题描述】:

使用 Sencha Touch 2.3.1a。我有一个使用 ListPaging 的列表:

{
    xtype: 'list',
    itemId: 'passDownList',
    store: 'PassDownEntrysStore',
    plugins: 
    [
        {
            xclass: 'Ext.plugin.ListPaging',
            autoPaging: true
        }
    ],
    grouped : true,
    itemTpl: '<div class="list-item-title">{time}</div><div class="list-item-narrative">{firstName} {lastName}</div>',
    selectedCls: 'list-item-module',
    itemCls: 'list-item-custom',
    onItemDisclosure: true,
}   

使用以下商店代理设置:

proxy: 
{
    type: 'ajax',
    actionMethods: 
    {
        read   : 'POST'
    },
    extraParams :
    {
    },
    url: App.config.Config.baseURL() + 'subscriptions/',
    reader: 
    {
        type: 'json',
        totalProperty: 'totalCount',
        //totalCount: 'totalCount',
        //total: 'totalCount',
        rootProperty: 'Data.items',
        successProperty: 'success'
    }
}

这是从服务器返回的数据:

我已经尝试了所有三种阅读器设置:

totalProperty: 'totalCount',
//totalCount: 'totalCount',
//total: 'totalCount',

并且 totalCount 始终为“未定义”。我尝试在商店中添加加载事件以更新总数:

load: function(records, successful, operation, eOpts)
{
    var data = JSON.parse(eOpts._response.responseText);

    this.setTotalCount(data.Data.totalCount);
    console.log('load call total: ' + this.getTotalCount());
}

设置它。但是,当我拉出列表以显示更多条目并检查加载事件中的总计数时,它再次被重置为“未定义”。
我希望它起作用的原因是它显示“没有更多记录”

更新:2014 年 6 月 18 日: 在负载上设置它对我有用:

load: function(records, successful, operation, eOpts)
{
var data = JSON.parse(eOpts._response.responseText);

this.setTotalCount(data.Data.totalCount);
console.log('load call total: ' + this.getTotalCount());
}

这就是它不断设置总数的原因。我仍然不明白为什么它会返回未定义,所以缺少/错误。但是现在这解决了我的分页问题

【问题讨论】:

    标签: sencha-touch


    【解决方案1】:

    实际上在阅读器配置中设置totalProperty: 'count' 对我有用,同时与 REST api 交互,但您的更新也可以正常工作。

    代理设置示例(顺便说一句,它不在商店配置中,而是在模型中)

        proxy: {
            type: 'rest',
            url : 'https://*******.info/api/v3/posts/',
            withCredentials: false,
            useDefaultXhrHeader: false,
            reader : {
                type : 'json',
                rootProperty : 'results',
                totalProperty : 'count'
    
            }
            //format  :'json'
        }
    

    【讨论】:

    • 我有 2.3.1a 版,我不是订阅者,所以在 2.3.2 可用之前无法下载。我将不得不等到那时。希望它只是一个错误。谢谢
    • 我也有 2.3.1,它(totalProperty 参数)按预期工作。与您的代码的一个区别 - 我使用服务器响应中的“count”参数而不是“totalCount”。不知道这是否重要。
    • 我只是尝试使用 count 也喜欢:count: 'totalCount' 什么都没有
    • 你可以发一个你的商店的例子来看看
    猜你喜欢
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多