我正在一个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
    }
});


在哪里可以定义其他参数?

最佳答案

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

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


或在您的代理配置中:

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

关于javascript - 使用附加参数进行Extjs分页,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25203596/

10-12 00:05
查看更多