0

我需要使用生成的 url 设置 ajax 请求。

Ext.define('Cc.store.Absences', {
    extend: 'Ext.data.Store',
  model: 'Cc.model.Absence',
  autoLoad: false,
  proxy: {
    type: 'ajax',
    url:  'person/user_id/absences', //I need a param to define user id 
    reader: {
      type: 'json'
    }
  }
});

我想我必须使用 Ext.data.Operation 但我不知道该怎么做。

4

2 回答 2

3

使用extraParams 更多信息

Ext.define('Cc.store.Absences', {
   extend: 'Ext.data.Store',
   model: 'Cc.model.Absence',
   autoLoad: false,
   proxy: {
     type: 'ajax',
     extraParams : {
        id : "123"
     },
     url:  'person/user_id/absences', //I need a param to define user id 
     reader: {
       type: 'json'
     }
   }
});
于 2011-05-19T10:09:02.963 回答
0

如果您希望动态生成 URL 并将其分配给商店,您可以按如下方式进行:

store.getProxy().url = '/person/' + user_id +'/absences';
store.load(); // need to reload your store.

要作为普通参数(POST 或 GET 方法)传递,您可以使用 Warung Nasi 解释的技术。

Ext.data.Operation如果您计划为商店代理自动生成用于排序、过滤、分组等的参数,则可以使用。您可以在Ext.data.proxy.Ajax 文档中了解可能的参数。请参阅 Url Generation 子标题。

于 2011-05-19T12:56:09.110 回答