2011-07-29 58 views
5

最近我使用directFn配置是這樣的:ExtJS4:爲什麼當我在我的商店使用directFn配置我需要指定directCfg.method作爲directFn財產

var store = new Ext.data.Store({ 
    proxy: { 
     type: 'direct', 
     directFn: myDirectfn, 
... 

,但它不會工作,因爲ExtJS的拋出異常

Uncaught TypeError: Cannot read property 'method' of undefined

在線

method = fn.directCfg.method; 
if (method.ordered) { 

在文件path/to/ext/src/data/proxy/Direct.js。經過一番挖掘,我發現fn是指myDirectfn函數。所以我剛剛添加了幾行:

myDirectfn.directCfg = { 
    method: {} 
}; 

在我的代碼中。之後,所有人開始正常工作(Here is fiddle)。

所以問題是:這個directCfg是什麼樣的神奇的東西?爲什麼需要?

回答

1

您必須在可以調用之前在Ext.app.REMOTING_API中定義遠程方法。在example given by reporter,該API頁面包括在內,定義了「TestAction」功能,通過代理稱爲:

Ext.ns("Ext.app"); 
Ext.app.REMOTING_API = {"url":"php\/router.php","type":"remoting","actions":{"TestAction":[{"name":"doEcho","len":1},{"name":"multiply","len":1},{"name":"getTree","len":1},{"name":"getGrid","len":1},{"name":"showDetails","params":["firstName","lastName","age"]}],"Profile":[{"name":"getBasicInfo","len":2},{"name":"getPhoneInfo","len":1},{"name":"getLocationInfo","len":1},{"name":"updateBasicInfo","len":0,"formHandler":true}]}}; 

一旦直接作用在Ext.app.REMOTING_API定義,該錯誤就會消失。

相關問題