I try to load a store, but for some reason I get this error in Google Chrome(latest version):
Uncaught TypeError: Cannot call method 'apply' of undefined ext-all-debug.js:8586
fire ext-all-debug.js:8586
Ext.define.continueFireEvent ext-all-debug.js:24623
Ext.define.fireEvent ext-all-debug.js:24601
Ext.define.onProxyLoad ext-all-debug.js:50186
Ext.define.processResponse ext-all-debug.js:39168
(anonymous function) ext-all-debug.js:39381
Ext.apply.callback ext-all-debug.js:6422
Ext.define.handleResponse ext-all-debug.js:18769
(anonymous function) ext-all-debug.js:1815
(anonymous function)
and this one in Internet Explorer 8:
Message: 'fireFn' is null or not an object
while FireFox(latest version) seems to ignore it.
I have inserted some new lines in ext-all-debug.js, so the line numbers may be off by 5-10 lines.
This is the store:
Ext.define("FI.store.units.InstallBaseStore", {
extend:'Ext.data.Store',
requires: "FI.model.units.InstallBaseModel",
model: "FI.model.units.InstallBaseModel",
storeId: 'installBaseStore',
pageSize:10,
proxy: {
type: 'jsonp',
url: urls.QSUrl+"/search",
limitParam: 'undefined',
startParam: 'offSet',
pageParam: 'undefined',
extraParams: {
searchString: '*:*',
index: "fleet",
role: "Admin"
},
reader: {
root: 'results.results',
totalProperty: 'numFound',
model: 'FI.model.units.InstallBaseModel'
}
},
listeners:{
beforeload: {
fn:function(){
console.log("BEFORE LOAD");
this.getProxy().setReader({
root: 'results.results',
totalProperty: 'numFound',
model: 'FI.model.units.InstallBaseModel'
});
console.log(this.getProxy().getReader());
}
}
}
});
Any ideas?
Put the proxy in the model, and do the reader like this:
...
proxy:{
type:'ajax',
url:'...',
reader:{
type:'json',
root:'...'
}
}
Related
Following scenario:
{
xtype: 'combo',
displayField: 'LANGTEXT',
valueField: 'KURZTEXT',
store: {
remoteSort: false,
autoLoad: false,
pageSize: 999999,
fields: [
{ name: 'KURZTEXT', type: 'string' },
{ name: 'LANGTEXT', type: 'string' }
],
proxy: {
type: 'ajax',
url: 'callHandler.cfc',
actionMethods: { read: 'POST' },
reader: {
type: 'json',
rootProperty: 'DATA.ROWS',
totalProperty: 'TOTALCOUNT'
}
},
listeners: {
load: function(store, records, successful, operation, eOpts ){
//is something like this possible?
var combo = store.getCombo()
}
}
}
}
Is it possible to get the combobox reference from the store with something like this: store.getCombo()? I know that normally you can only get the store reference from the combobox. But I thought maybe it works also the other way around, if the store is created in the combobox?
You may want to check the combobox afterQuery template method.
It's a configuration available for the combobox component that works almost similar to the store's load event. Here you have access to both the combobox component and the store.
I think the drawback is: it only gets called when the combo trigger is clicked or a value is typed in the combo's textfield. I believe this would already be help if you want to do your post-processing after these events.
{
xtype: 'combo',
displayField: 'LANGTEXT',
valueField: 'KURZTEXT',
store: {
remoteSort: false,
autoLoad: false,
pageSize: 999999,
fields: [
{ name: 'KURZTEXT', type: 'string' },
{ name: 'LANGTEXT', type: 'string' }
],
proxy: {
type: 'ajax',
url: 'callHandler.cfc',
actionMethods: { read: 'POST' },
reader: {
type: 'json',
rootProperty: 'DATA.ROWS',
totalProperty: 'TOTALCOUNT'
}
}
},
afterQuery: function (queryPlan) {
var combo = queryPlan.combo; // I guess `var combo = this;` should work too..
var store = combo.getStore();
// always return queryPlan
return queryPlan;
}
}
Let me know if you have any issue or questions.
The only solution I could think of was to write a custom matcher function.
You could do this by overriding the Ext.Component and adding the matcher function like this:
Ext.override(Ext.Component, {
hasStoreId: function (storeId) {
if (Ext.isFunction(this.getStore) && this.getStore().storeId) {
return this.getStore().storeId === storeId;
}
return false;
}
});
Now that you have a matcher function for every component you can search for all components with given storeId like this:
Ext.ComponentQuery.query("{hasStoreId('mystore')}");
You can also be more precise and only search for combos that match the criteria like this:
Ext.ComponentQuery.query("combo{hasStoreId('mystore')}");
Now that you have all combos with the given storeId you should easily be able to retrieve the combo you need.
Here a Sencha fiddle with a working example:
example code
I define a store in my extjs5 MVC project. I want to access cross domain cgi file so set proxy type: 'jsonp'.
After I load the store the Chrome show me "Uncaught SyntaxError: Unexpected token :"
Here is my store:
Ext.define('Myproject.store.MyStore', {
extend: 'Ext.data.Store',
model: 'Myproject.model.MyStore',
proxy: {
type: 'jsonp',
url: 'http://mylink:8000/setting.cgi',
extraParams: {
act: 'get_lib_list'
},
reader: {
type: 'json'
}
}
});
Response content:
{ "success": false, "error_code": 5006, "error_msg": "No such file or directory (-2)" }
How do I fix this problem?
Thanks
I am trying to link my grid with a store, which is using a proxy to connect to some outside source. This is how I have set it up :
Ext.define('js.dmwf.PackageStore', {
extend: 'Ext.data.JsonStore',
model: 'js.model.Package',
remoteFiler : false,
remoteSort: false,
autoLoad: true,
proxy: {
type: 'json',
url : 'mock/GetPackageListBB.json',
reader: {
type: 'json'
},
} });
However I am getting an error. Which is happening in the parseNamespace function in ext-all-debug.
Uncaught TypeError: Cannot read property 'substring' of undefined
ext-all-debug.js:5043
Ext.ClassManager.parseNamespace ext-all-debug.js:5043
I have a feeling that I am missing an import or two. However i think i have everything :
Ext.require([
'Ext.data.*',
'Ext.data.proxy.*',
'Ext.data.reader.*',
'Ext.grid.*',
'Ext.tree.*',
'Ext.ux.grid.FiltersFeature',
'Ext.toolbar.Paging',
'Ext.ux.form.SearchField',
'Ext.util.*',
'Ext.state.*'
// 'Ext.ux.grid.Search'
]);
I have a fiddle too :
https://fiddle.sencha.com/#fiddle/6jq
Proxy type needs to be 'ajax'.
proxy: {
type: 'ajax',
...
}
I am having a difficult time trying to access xml nodes that are not part of the record.
I would like to get the Success and Price node values.
Thanks!
An example xml would look like this
<Response>
<Success>true</Success>
<Document>
<DocumentHeaders>
<Price>1.99</Price>
</DocumentHeaders>
<DocumentItems>
<DocumentItem>
<Name>Test 1</Name>
</DocumentItem>
<DocumentItem>
<Name>Test 2</Name>
</DocumentItem>
</DocumentItems>
</Document>
</Response>
My data store:
Ext.regModel('DocumentItems', {
fields: [
{ name: 'Name', type: 'string' },
]
});
Ext.regStore('MyStore', {
model: 'DocumentItems',
proxy: {
type: 'ajax',
url: 'Service.asmx/Initialize',
reader: {
type: 'xml',
record: 'DocumentItem',
root: 'DocumentItems'
}
}
});
you can add this property to the reader successProperty: 'success' like this
reader: {
type: 'xml',
record: 'DocumentItem',
root: 'DocumentItems',
successProperty: 'success'
}
And for the price property I don't think there is another way then to modify your model to contain that property.
I've a ScriptTagProxy and I'm able to receive the data, but now I wanted to update a record. I've specified an url but only one url. Do I have to handle all the actions (read, update, create, delete) with this url?
If yes: how does the action is applied to the url?
If not: how I can specify more urls?
Here is the code I have so far:
app.stores.entries = new Ext.data.Store({
model: "app.models.Entry",
storeId: 'app.stores.entries',
proxy: {
type: 'scripttag',
url: 'http://myurl.de/getEntries.php',
extraParams: {
username: Ext.util.JSON.decode(window.localStorage.getItem('settings')).username,
password: Ext.util.JSON.decode(window.localStorage.getItem('settings')).password
},
reader: {
type: 'json'
},
writer: {
type: 'json'
}
}
});
I've read in the docs that you can pass an config object to the save function of a model to configurate the proxy.
So I tried following:
entry.save({
url: 'http://mysite.com/updateEntry.php',
extraParams: {
username: Ext.util.JSON.decode(window.localStorage.getItem('settings')).username,
password: Ext.util.JSON.decode(window.localStorage.getItem('settings')).password,
entry: entry
},}
As you see there is a url specified.
But I still get the error:
Uncaught Error: You are using a ServerProxy but have not supplied it with a url.
);
Same behaviour when using AjaxProxy or RestProxy for example :(
Hering,
With your first block of code you ask:
Question 1) "Do I have to handle all the actions (read, update, create, delete) with this url?"
The answer is yes.
Question 2) "If yes: how does the action is applied to the url?"
According to the Sencha source code you need to define the actionMethods like so:
myApp.stores.Things = new Ext.data.Store({
model: "Things", proxy: {
type: 'ajax',
actionMethods: {
create: 'POST',
read: 'GET',
update: 'PUT',
destroy: 'DELETE'
},
url: 'jsontest.json',
reader: {
type: 'json',
root: 'things'
}
},
autoLoad: true
});
If you delete, create or edit a record you must call:
store.sync();
There is also a "autoSave" property but it only syncs on edits, not removes.
This will send over the things that have changed or been deleted as part of the request payload, it is your responsibility to parse the json and handle it.
Hering,
I was reading the documentation here, I found this example in the Model class:
Ext.regModel('User', {
fields: ['id', 'name', 'email'],
proxy: {
type: 'rest',
url : '/users'
}
});
But above you don't show your Model for app.models.Entry, have you tried that?