javascript - Sencha touch 重置存储启动参数

标签 javascript sencha-touch sencha-touch-2

我有一个附加到列表的商店。该列表还使用 ListPaging 插件来启用分页。在我调用商店的 load 方法(或事件)后,商店将数据加载到列表中,并将请求发送到以下网址 -

http://localhost/mysite/nodelist.php?_dc=1359309895493
    &tids=1%2C4%2C2%2C5%2C67&page=1&start=0&limit=10

向下滚动列表并按加载更多...(由插件附加到列表中)后,商店会向同一网址发送另一个请求,但使用不同的参数,从而启用分页 -

http://localhost/mysite/nodelist.php?_dc=1359310357419
    &tids=1%2C4%2C2%2C5%2C67&page=2&start=10&limit=10 

现在我想重置商店的 startpage 参数的值。我尝试通过在代理上使用 setExtraParam 方法来重置它,但如果我这样做,那么控件不会维护分页 - 这意味着它不会自动更改 页面当我按加载更多...时,start参数。

那么我该怎么做呢?

这是我商店的示例代码 -

Ext.define('MyApp.store.MyStore', {
    extend: 'Ext.data.Store',
    requires: [
        'Ext.data.reader.Json',
        'Ext.data.proxy.Ajax'
    ],

    config: {
        autoLoad: false,
        model: 'MyApp.model.MyModel',
        serverUrl: null,
        pageSize: 2,
        proxy: {
            type: 'ajax',
            actionMethods: {
                read: 'GET'
            },
            url: null,
            reader: {
                type: 'json'
            }
        },
        listeners: {
            beforeload: function () {
                console.log('Before load');
            },
            load: function (store) {
                // console.log('load');
            }
        }
    }
});

这是 ListView -

list = {
    xtype: 'list',
    cls: 'myList',
    flex: 12,
    itemTpl: '{title}',
    store: 'MyStore',
    plugins: [
        {
            xclass: 'Ext.plugin.ListPaging',
            autoPaging: false
        }
    ],
    listeners: {
        select: {
            scope: this,
            fn: this.onSelect
        },
        swipe: {
            scope: this,
            element: 'element',
            fn: this.onListSwipe
        }
    }
};

最佳答案

从源码来看,也许你正在寻找currentPage商店的配置?

当您使用 ListPaging 插件加载更多录音时,它所做的就是调用存储中的 nextPage,然后使用 currentPage 配置调用 loadPage 。如果您将商店中的 currentPage 配置重置回 1,它只会假设起始位置返回到 0,并且页面当然是 1。

关于javascript - Sencha touch 重置存储启动参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14550550/

相关文章:

sencha-touch - sencha 应用程序构建 native 失败。给出错误 : <x-load-properties> does not support the <file> nested element

javascript - 在 Sencha Touch 中动态加载和初始化 Controller

javascript - Sencha Touch 2.1.0 如何让列表高度自动增加

android - 在 sencha 触摸 Controller 中调用 android 函数

javascript - 使用正则表达式验证输入中是否包含任何非数字

javascript - Firefox window.opener 问题

javascript - 如何在 Sequelize 中创建准备好的语句?

javascript - 在上一次和下一次单击时为 <LI> 添加类

javascript - 移动应用程序中的 PDF.JS Access-Control-Allow-Origin 问题

android - 从 webview 访问原生 android 方法