Example: http://www.mhzg.net/a/20115/20115311100255.html to learn extjs MVC mode. An invalid store specified by searchfield in view of extjs 4 MVC mode is encountered.
App. js
Ext.Loader.setConfig({enabled: true});Ext.Loader.setPath('Ext.ux', 'extjs/ux');Ext.require([ 'Ext.grid.*', 'Ext.toolbar.Paging', 'Ext.util.*', 'Ext.data.*', 'Ext.panel.Panel', 'Ext.view.View', 'Ext.layout.container.Fit', 'Ext.ux.form.SearchField']);
Definition in view
Ext. define ('bjxc. view. phonebrand. list', {extend: 'ext. grid. panel ', alias: 'widget. phonebrandlist', // the alias is userlist ID: 'phonebrandlistgrid ', Title: 'phone brands', iconcls: 'icon-user', store: 'phonebrand', columnlines: True, columns: [{header: 'sequence number ', dataindex: 'id', width: 40}, {header: 'Chinese abbreviation', dataindex: 'zwm ', flex: 1 }, {header: 'English name', dataindex: 'ywm ', flex: 1}, {header: 'Chinese full name', dataindex: 'zwqc', flex: 1 }, {header: 'website', dataindex: 'fwz', flex: 1}, {header: 'Customer Service hot', dataindex: 'kfdh', flex: 1}, {header: 'Customer Service address', dataindex: 'kfdz', flex: 1}], viewconfig: {striperows: True, // display zebra crossing enabletextselection: True // enable Text Selection}, dockeditems: [{DOCK: 'top', xtype: 'toolbar', items: [{iconcls: 'icon-add', text: 'add', Action: 'add', scope: this}, {iconcls: 'icon-delete', text: 'delete', Action: 'delete', scope: This}, '-', {xtype: 'searchfield ', width: 300, fieldlabel: 'search', labelwidth: 50, store: 'phonebrand'}]}, {DOCK: 'bottom ', xtype: 'pagingtoolbar', store: 'phonebrand', displayinfo: True, pagesize: 10, emptymsg: 'No record'}]});
The following error occurs during execution:
Typeerror: Me. Store. Proxy is undefined [interrupted here] If (! Me. Store. Proxy. hasownproperty ('filterparam ')){
Search information, get the following url: http://www.sencha.com/forum/showthread.php? 208604-error-with-searchfield-and-the-error-is-me.store.proxy-is-undefined
me.store is defined, just is a string.
Http://www.sencha.com/forum/showthread.php? 131842-4.0.0-mvc-grid-store-problems-grouping-and-searchfield
the same problem, grouping feature doesn't work when we respect the MVC pattern. If the store is defined as a var then works.
That is to say, the store: 'phonebrand' specified in the view is actually a string and is not a variable. In the above example, store is a created variable.
Open \ extjs \ UX \ form \ searchfield. js and add the following code in around 22 lines. Patch it.
if(typeof(me.store.isStore) == 'undefined') { me.store = Ext.data.StoreManager.get(me.store); }
In the store code, you must specify the storeid, for example, storeid: 'phonebrand ',
The complete Ext. UX. Form. searchfield code is as follows: extjs 4.1.1a.
Ext.define('Ext.ux.form.SearchField', { extend: 'Ext.form.field.Trigger', alias: 'widget.searchfield', trigger1Cls: Ext.baseCSSPrefix + 'form-clear-trigger', trigger2Cls: Ext.baseCSSPrefix + 'form-search-trigger', hasSearch : false, paramName : 'query', initComponent: function() { var me = this; me.callParent(arguments); me.on('specialkey', function(f, e){ if (e.getKey() == e.ENTER) { me.onTrigger2Click(); } }); // console.log(me.store); // console.log(me.store.isStore); if(typeof(me.store.isStore) == 'undefined') { me.store = Ext.data.StoreManager.get(me.store); } // We're going to use filtering me.store.remoteFilter = true; // Set up the proxy to encode the filter in the simplest way as a name/value pair // If the Store has not been *configured* with a filterParam property, then use our filter parameter name if (!me.store.proxy.hasOwnProperty('filterParam')) { me.store.proxy.filterParam = me.paramName; } me.store.proxy.encodeFilters = function(filters) { return filters[0].value; } }, afterRender: function(){ this.callParent(); this.triggerCell.item(0).setDisplayed(false); }, onTrigger1Click : function(){ var me = this; if (me.hasSearch) { me.setValue(''); me.store.clearFilter(); me.hasSearch = false; me.triggerCell.item(0).setDisplayed(false); me.updateLayout(); } }, onTrigger2Click : function(){ var me = this, value = me.getValue(); if (value.length > 0) { // Param name is ignored here since we use custom encoding in the proxy. // id is used by the Store to replace any previous filter me.store.filter({ id: me.paramName, property: me.paramName, value: value }); me.hasSearch = true; me.triggerCell.item(0).setDisplayed(true); me.updateLayout(); } }});
With searchfield. js changed, you can directly specify the store in the view.