-
Problem with DirectStore
Hello.
I am trying to use Direct b DirectStore in my application, but I have some problems with them.
I write in MVC style and add in my app.js file this:
Code:
Ext.direct.Manager.addProvider({
'type': 'remoting',
'url': '/places/remoting/router/',
'namespace': 'Recruitant.places',
'actions': {
'city': [
{
'formHandler': false,
'name': 'load_cities',
'len': 1
}
]
}
});
Recruitant.places.city.load_cities();
This code work fine, but I try to define Model like this:
Code:
Ext.define('Recruitant.model.City', {
extend: 'Ext.data.Model',
proxy: {
type: 'direct',
url: '/places/remoting/router/',
directFn: 'Recruitant.places.city.load_cities'
},
fields: [
{name: 'id', type: 'int'},
{name: 'name', type: 'string'}
]
});
and DirectStore like this:
Code:
Ext.define('Recruitant.store.Cities', {
extend: 'Ext.data.DirectStore',
model: 'Recruitant.model.City'
});
and in my firebug have error "fn is undefined".
Help me to solve this problem, please.
-
My code works if I create grid, store and other objects in app.js, but it is not work if I write Store, Model and other stuff with Ext.define.
-
On the client side, remove the quotes around the directFn specification: it needs to be a function, not a strong.
You have:
directFn: 'Recruitant.places.city.load_cities'
You should have:
directFn: Recruitant.places.city.load_cities
-
@oniseijin - not true, docs say: "The directFn may also be a string reference to the fully qualified name of the function, for example: 'MyApp.company.GetProfile'. This can be useful when using dynamic loading. The string will be looked up when the proxy is created."
I am using it as a string in my application now and it is necessary in case the JS gets loaded out of order, although I have gotten intermittent errors about the directFn is null whether I use the string or function symbol format