ExtJS4: Why when I use directFn config in my store I need to specify directCfg.method as directFn's property

ⅰ亾dé卋堺 提交于 2019-12-06 03:02:37

问题


Recently I was using directFn config like this:

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

But it wouldn't work because ExtJS threw exception

Uncaught TypeError: Cannot read property 'method' of undefined

at the lines

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

in file path/to/ext/src/data/proxy/Direct.js. After some digging I've found out that fn refers to myDirectfn function. So I've just added lines:

myDirectfn.directCfg = {
    method: {}
};

in my code. After that all started to work properly (Here is fiddle).

So the question is: What kind of magical thing is this directCfg? Why is it needed?


回答1:


I think you are using directFn inappropriately. directFn has to be used in tandem with Ext.direct.RemotingProvider. Check out official example.




回答2:


You have to define the remote method in Ext.app.REMOTING_API before in can be called. In the example given by reporter, the api page is included and defines the "TestAction" function called by the proxy:

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}]}};

Once the direct function is defined in the Ext.app.REMOTING_API, that error should go away.



来源:https://stackoverflow.com/questions/6873534/extjs4-why-when-i-use-directfn-config-in-my-store-i-need-to-specify-directcfg-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!