在 ExtJS 內,我們會用 Proxy 來載入 Store 內容。以下是 Proxy 會自動加入的參數 :
- start - (number) 像 SQL 的 offset
- limit - (number) 像 SQL 的 limit
- page - (number) 頁數
- sort - (string) JSON format 的字串,用來排列結果
但是有時我們可能需要加入更多的參數才可以抽出資料,那應該要怎樣做呢?
### 動態方法
可以通過使用 `Proxy.setExtraParams()` 來動態設定額外的參數。
```js
grid.getStore().getProxy().setExtraParams({
foo: 'bar'
});
grid.getStore().load();
```
### 靜態方法
可以通過加入 `extraParams` 到 Proxy 來設定額外的參數。
```js
new Ext.data.Store({
autoLoad: true,
proxy: {
url: 'users.php',
type: 'ajax',
extraParams: {
foo: 'bar'
}
}
});
```