【问题标题】:Extjs Paging with additional Parameter带有附加参数的 Extjs 分页
【发布时间】:2014-08-08 21:05:15
【问题描述】:

我正在开发一个 ExtJS 4.2 项目,我想在其中使用分页工具栏来浏览图像。 当我打开窗口时,所有图像都是正确的,但是当我单击下一个按钮查看下一个图像时,结果为空。这是因为参数 ID 没有传递给后端系统。 我在其他线程中看到了像 baseParams 这样的选项,但它们不在文档中并且不起作用。

//My Store Class
Ext.define('App.store.Images', {
  extend: 'Ext.data.Store',
  model: 'App.model.Images',
  autoLoad: false,
  autoSync: false,
  storeId: 'Images',
  pageSize: 8,
  proxy: {
    type: 'ajax',
    url: '/getImages',
    reader: {
        type: 'json',
        root: 'images',
        totalProperty: 'total'
    }
  }
});
// This code is execute when i open the Window
var imagesStore = Ext.StoreManager.get('Images');
imagesStore.on('load', buildContent);
imagesStore.load({
    params: {
        id: record.get('id'),
        start: 0,
        limit: 8
    }
});

在哪里可以定义附加参数?

【问题讨论】:

    标签: javascript extjs pagination


    【解决方案1】:

    事实上,您可以在存储代理上定义 extraParams。您可以在调用 load 方法之前执行此操作:

    Ext.apply(store.getProxy().extraParams, {
        'yourId': yourId
    });
    

    或在您的代理配置中:

    proxy: {
        type: 'ajax',
        url: '/getImages',
        reader: {
            type: 'json',
            root: 'images',
            totalProperty: 'total'
        }
        extraParams: {
            'yourId': yourId
        }
    }
    

    【讨论】:

    • 谢谢。我只在Ext.data.proxy.Proxy 页面上寻找baseParamsextraParams 而不是在Ext.data.proxy.Ajax 页面上
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-17
    • 1970-01-01
    • 2017-01-31
    • 1970-01-01
    • 2016-07-12
    • 1970-01-01
    相关资源
    最近更新 更多