Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Don't miss up with ExtJs. I know, it could be a pain ...</p> <p>For your problem, I solved this way:</p> <p>I have a grid that list municipalities of Italy. I want to filter by country, region and province, so I put three comboboxes on a docked container. In the controller I have:</p> <pre class="lang-js prettyprint-override"><code> ,init : function (application) { this.control({ ,"#municipalitiesGrid": { afterrender: this.onMunicipalitiesGridAfterRender } }); } ,onMunicipalitiesGridAfterRender: function(grid, opts) { console.info('GVD.controller.Geo-&gt;onMunicipalitiesGridAfterRender'); var store = grid.getStore(), comboCountriesMunicipalities = this.getComboCountriesMunicipalities(), storeCountries = comboCountriesMunicipalities.getStore(), comboRegionsMunicipalities = this.getComboRegionsMunicipalities(), storeRegions = comboRegionsMunicipalities.getStore(), comboProvincesMunicipalities = this.getComboProvincesMunicipalities(), storeProvinces = comboProvincesMunicipalities.getStore(); store.clearFilter(true); storeCountries.clearFilter(true); storeRegions.clearFilter(true); storeProvinces.clearFilter(true); storeRegions.filter("idCountry", 114); // 114 = Italia storeProvinces.filter("idRegion",8); // 8 = Emilia Romagna store.filter("idProvince", 37); // 37 = Bologna storeCountries.load({ scope: this, callback: function(records, operation, success) { storeRegions.load({ scope: this, callback: function(records, operation, success) { storeProvinces.load({ scope: this, callback: function(records, operation, success) { store.load({ scope: this, callback: function(records, operation, success) { comboCountriesMunicipalities.setValue(114); // 114 = Italia comboRegionsMunicipalities.setValue(8); // 8 = Emilia Romagna comboProvincesMunicipalities.setValue(37); // 37 = Bologna } }); } }); } }); } }); } </code></pre> <p>In the controller, of course, I have other listeners for comboboxes's 'select' event, so I can filter and reload combo according to the values selected.</p> <p>Following MVC patter, my stores are similar to this:</p> <pre><code>Ext.define('GVD.store.Municipalities', { extend: 'Ext.data.Store' ,constructor: function(cfg) { console.info('GVD.store.Municipalities-&gt;constructor'); var me = this; cfg = cfg || {}; me.callParent([Ext.apply({ autoLoad: false ,autoSync: true ,model: 'GVD.model.Municipalities' ,pageSize: 20 }, cfg)]); } }); </code></pre> <p>And models similar to:</p> <pre><code>Ext.define('GVD.model.Municipalities', { extend: 'Ext.data.Model', fields: [ { name: 'id', type: 'int' }, { name: 'idIstat', type: 'int' }, { name: 'idCountry', type: 'int' }, { name: 'idRegion', type: 'int' }, { name: 'idProvince', type: 'int' }, { name: 'name', type: 'string' }, { name: 'chief_town', type: 'boolean' }, { name: 'altitude_zone', type: 'int' }, { name: 'altitude', type: 'int' }, { name: 'coastal', type: 'int' }, { name: 'mountain', type: 'int' }, { name: 'surface', type: 'double' }, { name: 'residents', type: 'int' }, { name: 'icon', type: 'string' } ] ,proxy: { api: { create: 'Municipalities.create' ,destroy: 'Municipalities.destroy' ,read: 'Municipalities.read' ,update: 'Municipalities.update' } ,reader: { root: 'data' ,totalProperty: 'totalCount' ,type: 'json' } ,type: 'direct' } }); </code></pre> <p>And referenced in my grid this way:</p> <pre><code>Ext.define('GVD.view.system.geo.ListMunicipalities', { autoScroll: true ,constrain: true ,dockedItems: [{ xtype: 'topBar' },{ items: [{ allowBlank: true ,fieldLabel: 'Nazione' ,flex: 1 ,id: 'comboCountriesMunicipalities' ,labelAlign: 'right' ,labelWidth: 50 ,listConfig: { getInnerTpl: function() { return '&lt;img src="resources/images/countries/16/{icon}16.gif" align="left"&gt;&amp;nbsp;&amp;nbsp;{italianName}'; } } ,store: Ext.create('GVD.store.Countries', {pageSize: 999}) ,xtype: 'comboCountries' },{ allowBlank: true ,fieldLabel: 'Regione' ,flex: 1 ,id: 'comboRegionsMunicipalities' ,labelAlign: 'right' ,labelWidth: 50 ,listConfig: { getInnerTpl: function() { return '&lt;img src="resources/images/regions/16/{icon}16.gif" align="left"&gt;&amp;nbsp;&amp;nbsp;{name}'; } } ,store: Ext.create('GVD.store.Regions', {pageSize: 999}) ,xtype: 'comboRegions' },{ allowBlank: true ,fieldLabel: 'Provincia' ,flex: 1 ,id: 'comboProvincesMunicipalities' ,labelAlign: 'right' ,labelWidth: 50 ,listConfig: { getInnerTpl: function() { return '&lt;img src="resources/images/provinces/16/{icon}16.gif" align="left"&gt;&amp;nbsp;&amp;nbsp;{name}'; } } ,store: Ext.create('GVD.store.Provinces', {pageSize: 999}) ,xtype: 'comboProvinces' }] ,layout: 'hbox' ,xtype: 'container' }, { dock: 'bottom' ,itemId: 'municipalitiesPagingToolbar' ,store: 'Municipalities' ,xtype: 'pagingToolBar' }] ,extend: 'Ext.window.Window' ,height: 400 ,icon: 'resources/images/GVD/municipalities16.png' ,id: 'listMunicipalities' ,items: [{ columns: [{ xtype: 'rownumberer' },{ align: 'right' ,dataIndex: 'id' ,format: '000' ,renderer: function(value, metaData, record, rowIndex, colIndex, store, view) { return '&lt;img src="resources/images/municipalities/16/'+record.data.icon+'16.gif" align="left"&gt;&amp;nbsp;&amp;nbsp;'+record.data.id; } ,text: 'Id' ,width: 70 ,xtype: 'numbercolumn' },{ align: 'right' ,dataIndex: 'idIstat' ,editor: { allowBlank: false, selectOnFocus: true } ,filter: { type: 'numeric' } ,format: '000000000' ,text: 'Istat' ,width: 80 ,xtype: 'numbercolumn' },{ dataIndex: 'name' ,editor: { allowBlank: false, selectOnFocus: true } ,filter: { type: 'string' } ,flex: 1 ,text: 'Denominazione' ,xtype: 'gridcolumn' },{ dataIndex: 'chief_town' ,editor: { allowBlank: false, selectOnFocus: true } ,filter: { type: 'numeric' } ,text: 'Capoluogo' ,width: 40 ,xtype: 'numbercolumn' },{ dataIndex: 'altitude_zone' ,editor: { allowBlank: false, selectOnFocus: true } ,filter: { type: 'numeric' } ,format: '0' ,text: 'Zona alt.' ,width: 40 ,xtype: 'numbercolumn' },{ align: 'right' ,dataIndex: 'altitude' ,editor: { allowBlank: false, selectOnFocus: true } ,filter: { type: 'numeric' } ,format: '0000' ,text: 'Altitudine' ,width: 40 ,xtype: 'numbercolumn' },{ dataIndex: 'coastal' ,editor: { allowBlank: false, selectOnFocus: true } ,filter: { type: 'numeric' } ,format: '0' ,text: 'Costiero' ,width: 40 ,xtype: 'numbercolumn' },{ dataIndex: 'mountain' ,editor: { allowBlank: false, selectOnFocus: true } ,filter: { type: 'numeric' } ,format: '0' ,text: 'Montano' ,width: 40 ,xtype: 'numbercolumn' },{ align: 'right' ,dataIndex: 'surface' ,editor: { allowBlank: false, selectOnFocus: true } ,filter: { type: 'numeric' } ,format: '000,000.00' ,text: 'Superficie' ,xtype: 'numbercolumn' },{ align: 'right' ,dataIndex: 'residents' ,editor: { allowBlank: false, selectOnFocus: true } ,filter: { type: 'numeric' } ,format: '0,000,000' ,text: 'residenti' ,xtype: 'numbercolumn' },{ dataIndex: 'icon' ,editor: { allowBlank: false, selectOnFocus: true } ,filter: { type: 'string' } ,flex: 1 ,text: 'Icona' ,xtype: 'gridcolumn' }] ,columnLines: true ,emptyText: '&lt;font color="red"&gt;&lt;b&gt;Nessun comune in archivio&lt;/b&gt;&lt;/font&gt;' ,features: [ Ext.create('GVD.ux.grid.FiltersFeature', { encode: true, ftype: 'filters', local: false, menuFilterText: 'Filtro' }) ] ,id: 'municipalitiesGrid' ,plugins: [ Ext.create('Ext.grid.plugin.RowEditing', { ptype: 'rowediting' }) ] ,selModel: { selType: 'checkboxmodel', mode: 'MULTI' },store: 'Provinces' ,store: 'Municipalities' ,viewConfig: { loadingText: 'Caricamento dati' ,stripeRows: true ,trackOver: true } ,xtype: 'grid' }] ,layout: { align: 'stretch' ,type: 'vbox' } ,margin: '0 0 2 0' ,maximizable: true ,minimizable: true ,requires: [ 'GVD.ux.combo.Countries' ,'GVD.ux.combo.Provinces' ,'GVD.ux.combo.Regions' ,'GVD.ux.PrintButton' ,'GVD.ux.toolbar.BottomBar' ,'GVD.ux.toolbar.PagingToolBar' ,'GVD.ux.toolbar.TopBar' ] ,singleWindow: true ,title: 'Elenco comuni' ,tools: [ { xtype: 'printButton', title: 'Elenco Comuni', tooltip: 'Stampa elenco' } ,{ type: 'help', xtype: 'tool', tooltip: 'Guida sulla funzione' } ] ,width: 760 }); </code></pre> <p>Hope this can help.</p> <p>bye</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload