简体   繁体   中英

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 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM