Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let's see the example below of using two combobox controls bound to two different stores. Changing first combobox raises event which reload (in my example it do filters) the data accordingly to the selected value. Then the store of the second combobox is reloaded and the control refilled. </p> <p>This example shows how both model, store and view are cooperate and used together. Generally it uses local data collection, but you can easily to configure the store and proxy so it will bring the data from the server side: </p> <pre><code> // Set up a model to use in our Store Ext.define('Countries', { extend: 'Ext.data.Model', fields: [ {name: 'abbr', type: 'string'}, {name: 'name', type: 'string'} ] }); // The data store containing the list of states var countries = Ext.create('Ext.data.Store', { fields: ['abbr', 'name'], model: 'Countries', data : [ {"abbr":"US", "name":"United States"}, {"abbr":"FR", "name":"France"} //... ] }); // Set up a model to use in our Store Ext.define('States', { extend: 'Ext.data.Model', fields: [ {name: 'cntry', type: 'string'}, {name: 'abbr', type: 'string'}, {name: 'name', type: 'string'} ] }); // The data store containing the list of states var states = Ext.create('Ext.data.Store', { autoLoad: false, fields: ['abbr', 'name'], model: 'States', data : [ {"cntry": "US", "abbr":"AL", "name":"Alabama"}, {"cntry": "US", "abbr":"AK", "name":"Alaska"}, {"cntry": "US", "abbr":"AZ", "name":"Arizona"}, {"cntry": "FR", "abbr":"PR", "name":"Paris"} //... ], listeners: { beforeload: function () { } } }); // Create the combo box, attached to the states data store var a = Ext.create('Ext.form.ComboBox', { fieldLabel: 'Choose Country', store: countries , queryMode: 'local', displayField: 'name', valueField: 'abbr', // Basically this code was tested on Simple Online ExtJS Code Editor // http://ext4all.com/post/simple-online-extjs-code-editor // so it was bounded to the codeoutput control renderTo: 'codeoutput', listeners: { // when we change the value of Countries combobox, this event is raised change: function(obj, newVal, oldVal, eOpts) { // we can also use states.filter() function in the same way states.filterBy ( function(record, id) { // newVal variable is available due to closure, so we can compare the row with the selected country and result appropriate notification if (record.get("cntry")==newVal) return true; }); } } }); // Create the combo box, attached to the states data store var a = Ext.create('Ext.form.ComboBox', { fieldLabel: 'Choose State', store: states, queryMode: 'local', displayField: 'name', valueField: 'abbr', renderTo: 'codeoutput' }); </code></pre>
    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. This table or related slice is empty.
    1. 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