View Full Version : error: store not defined

30 Apr 2013, 3:21 AM
if i want to make a different store in this code then it says store not defined
here is the code
Js file
Ext.define('MyApp.view.new', {
extend: 'Ext.form.ComboBox',

queryMode: 'remote',
displayField: 'name',
valueField: 'abbr',
forceSelection: true,
id: 'searchId',
labelWidth: 150,
fieldLabel: 'Search',
size: 50,
maxLength: 50,
allowBlank : false,
name: 'AppSearch',

minChars: 1,
typeAhead: true,
store: 'searchStore',
listeners: {
buffer: 50,
change: function() {
var store = this.store;

property: 'name',
anyMatch: true,
value : this.getValue()



Ext.define('MyApp.store.searchStore', {
extend: 'Ext.data.Store',

requires: [

constructor: function(cfg) {
var me = this;
cfg = cfg || {};
model: 'MyApp.model.searchModel',
storeId: 'HeaderStoreId',
proxy: {
type: 'ajax',
url: 'http://localhost:8080/combo/view/data/data.json',
reader: {
type: 'json',
root: 'SearchData'
writer: {
type: 'json'
}, cfg)]);

Ext.define('MyApp.model.searchModel', {
extend: 'Ext.data.Model',

fields: [
name: 'abbr'
name: 'name'
name: 'slogan'
Json file
"success": true,
"SearchData": [
"name": 'Virginia',
"slogan":'Mother of States'
"name": 'Washington',
"slogan":'Green Tree State'
"name": 'West Virginia',
"slogan":'Mountain State'
"name": 'Wisconsin',
"slogan":'America\'s Dairyland'
"name": 'Wyoming',
"slogan":'Like No Place on Earth'


in this code error is store is undefined.
please tell me where is the mistake.

1 May 2013, 4:20 PM
If you're setting your application up using Ext.application and have your controllers setting up a store using the stores config on a controller then the controller will auto-create an instance of that store (MyApp.store.searchStore in your case) and that store instance will have a storeId of searchStore. Then you can use that to reference the store like in your config - store: 'searchStore'.

If you're not using an MVC build with Ext.application then you'll need to first create an instance of the MyApp.store.searchStore. You could do that prior to creating the combo and either in the creation of it set the storeId to 'searchStore' or you can put the storeId in the store definition and then you can call up that store instance using the storeId like in your example.