Reputation: 10624
I want to define the data.store that store companyList, because I want to reuse this store later.
tbar: Ext.create('Ext.Toolbar', {
items: [
{
xtype : 'combo',
name : 'companyCode',
editable : false,
valueField : 'companyCode',
displayField : 'companyName',
triggerAction : 'all',
store: Ext.create('Ext.data.Store', {
fields: ['companyCode', 'companyName'],
proxy: {
type: 'ajax',
url: '/Reports/GetCompanyList/',
reader: 'json',
actionMethods: {
read: 'POST'
}
},
autoLoad:true
})
The above code is work, and I want to put the store into my store folder under the app folder.
store/CompanyList_store.js
Ext.define('App.store.CompanyList_store', {
extend: "Ext.data.Store",
fields: ['companyCode', 'companyName'],
proxy: {
type: 'ajax',
url: '/Reports/GetCompanyList/',
reader: 'json',
actionMethods: {
read: 'POST'
}
},
autoLoad: true
});
and I add this store in controller.
Ext.define("App.controller.InventoryReport", {
extend: "Ext.app.Controller",
stores: ['Inventory_store', 'CompanyList_store'],
.
.
and add this store to combo box store,
tbar: Ext.create('Ext.Toolbar', {
items: [
{
xtype : 'combo',
name : 'companyCode',
editable : false,
valueField : 'companyCode',
displayField : 'companyName',
triggerAction : 'all',
store: 'CompanyList_store' //it does not work.
What I am doing wrong? If anybody knows, please advice me.
Upvotes: 0
Views: 1785
Reputation: 1955
I think you forgot to include all stores in your application file.
It should be something like this:
Ext.application({
appFolder: ...
controllers: [your controllers here],
stores: [your stores here]
});
And if you place your store in different folder (to share them between ext apps) be sure you included the following:
Ext.Loader.setPath([namespace], [path to the folder with stores]
)
Upvotes: 1
Reputation: 48246
Gotta set the storeId property on the store, to the value that you call from the combo
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.AbstractStore-cfg-storeId
In real life though, I would recommend using Deft's dependency injection.
Upvotes: 1