开发者

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

Recently I was using directFn co开发者_JAVA百科nfig 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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜