1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5 <title>Combo Boxes</title>
6 <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
7 <link rel="stylesheet" type="text/css" href="../../resources/css/xtheme-gray.css" />
11 <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
14 <script type="text/javascript" src="../../ext-all.js"></script>
16 <script type="text/javascript" src="states.js"></script>
17 <script type="text/javascript" src="combos.js"></script>
18 <link rel="stylesheet" type="text/css" href="combos.css" />
20 <!-- Common Styles for the examples -->
21 <link rel="stylesheet" type="text/css" href="../shared/examples.css" />
22 <style type="text/css">
27 <script type="text/javascript" src="../shared/examples.js"></script><!-- EXAMPLES -->
29 <p>The js is not minified so it is readable. See <a href="combos.js">combos.js</a>.</p>
32 <b>Data Sources</b><br />
33 The combo box can use any type of Ext.data.Store as its data source.
34 This means your data can be XML, JSON, arrays or any other supported format. It can be loaded using
35 Ajax, via script tags or locally. This combo uses local data from a JS array:</p>
37 <input type="text" id="local-states" size="20"/>
39 <div id="state-combo-code-panel" style="margin-top:10px">
40 <pre id="state-combo-code" class="code"><code>// simple array store
41 var store = new Ext.data.SimpleStore({
42 fields: ['abbr', 'state'],
45 var combo = new Ext.form.ComboBox({
51 emptyText:'Select a state...',
53 applyTo: 'local-states'
59 The combo below uses the same data, but also illustrates how to use an optional
60 custom template to create custom UI renditions for list items. In this case,
61 each item has a popup QuickTip which displays the state's nickname when hovered over.
64 <input type="text" id="local-states-with-qtip" size="20"/>
66 <div id="state-combo-qtip-code-panel" style="margin-top:10px">
67 <pre id="state-combo-qtip-code" class="code"><code>// simple array store
68 var store = new Ext.data.SimpleStore({
69 fields: ['abbr', 'state', 'nick'],
72 var comboWithTooltip = new Ext.form.ComboBox({
73 tpl: '<tpl for="."><div ext:qtip="{state}. {nick}" class="x-combo-list-item">{state}</div></tpl>',
79 emptyText:'Select a state...',
81 applyTo: 'local-states-with-qtip'
87 The combo box can also use plain array data directly as its data source, wrapping the array internally
88 with a SimpleStore as needed. You can pass a 1-dimensional or multi-dimensional array as the store config:</p>
90 <input type="text" id="array-states" size="20"/>
92 <div id="array-combo-code-panel" style="margin-top:10px">
93 <pre id="array-combo-code" class="code"><code>var comboFromArray = new Ext.form.ComboBox({
94 store: exampleData, //direct array data
97 emptyText:'Select a state...',
99 applyTo: 'array-states'
105 <b>Unobtrusive</b><br />
106 The combo box can very easily be used to convert existing select elements into auto-completing, filtering combos.
109 Transformed select:<br/> <select name="state" id="state">
110 <option value="AL">Alabama</option>
111 <option value="AK">Alaska</option>
112 <option value="AZ">Arizona</option>
113 <option value="AR">Arkansas</option>
114 <option value="CA">California</option>
115 <option value="CO">Colorado</option>
116 <option value="CT">Connecticut</option>
117 <option value="DE">Delaware</option>
118 <option value="FL">Florida</option>
119 <option value="GA">Georgia</option>
120 <option value="HI">Hawaii</option>
121 <option value="ID">Idaho</option>
122 <option value="IL">Illinois</option>
123 <option value="IN">Indiana</option>
124 <option value="IA">Iowa</option>
125 <option value="KS">Kansas</option>
126 <option value="KY">Kentucky</option>
127 <option value="LA">Louisiana</option>
128 <option value="ME">Maine</option>
129 <option value="MD">Maryland</option>
130 <option value="MA">Massachusetts</option>
131 <option value="MI">Michigan</option>
132 <option value="MN">Minnesota</option>
133 <option value="MS">Mississippi</option>
134 <option value="MO">Missouri</option>
135 <option value="MT">Montana</option>
136 <option value="NE">Nebraska</option>
137 <option value="NV">Nevada</option>
138 <option value="NH">New Hampshire</option>
139 <option value="NJ">New Jersey</option>
140 <option value="NM">New Mexico</option>
141 <option value="NY">New York</option>
142 <option value="NC">North Carolina</option>
143 <option value="ND">North Dakota</option>
144 <option value="OH" selected>Ohio</option>
145 <option value="OK">Oklahoma</option>
146 <option value="OR">Oregon</option>
147 <option value="PA">Pennsylvania</option>
148 <option value="RI">Rhode Island</option>
149 <option value="SC">South Carolina</option>
150 <option value="SD">South Dakota</option>
151 <option value="TN">Tennessee</option>
152 <option value="TX">Texas</option>
153 <option value="UT">Utah</option>
154 <option value="VT">Vermont</option>
155 <option value="VA">Virginia</option>
156 <option value="WA">Washington</option>
157 <option value="WV">West Virginia</option>
158 <option value="WI">Wisconsin</option>
159 <option value="WY">Wyoming</option>
163 Originally looked like:<br/> <select name="state-orig">
164 <option value="AL">Alabama</option>
165 <option value="AK">Alaska</option>
166 <option value="AZ">Arizona</option>
167 <option value="AR">Arkansas</option>
168 <option value="CA">California</option>
169 <option value="CO">Colorado</option>
170 <option value="CT">Connecticut</option>
171 <option value="DE">Delaware</option>
172 <option value="FL">Florida</option>
173 <option value="GA">Georgia</option>
174 <option value="HI">Hawaii</option>
175 <option value="ID">Idaho</option>
176 <option value="IL">Illinois</option>
177 <option value="IN">Indiana</option>
178 <option value="IA">Iowa</option>
179 <option value="KS">Kansas</option>
180 <option value="KY">Kentucky</option>
181 <option value="LA">Louisiana</option>
182 <option value="ME">Maine</option>
183 <option value="MD">Maryland</option>
184 <option value="MA">Massachusetts</option>
185 <option value="MI">Michigan</option>
186 <option value="MN">Minnesota</option>
187 <option value="MS">Mississippi</option>
188 <option value="MO">Missouri</option>
189 <option value="MT">Montana</option>
190 <option value="NE">Nebraska</option>
191 <option value="NV">Nevada</option>
192 <option value="NH">New Hampshire</option>
193 <option value="NJ">New Jersey</option>
194 <option value="NM">New Mexico</option>
195 <option value="NY">New York</option>
196 <option value="NC">North Carolina</option>
197 <option value="ND">North Dakota</option>
198 <option value="OH" selected>Ohio</option>
199 <option value="OK">Oklahoma</option>
200 <option value="OR">Oregon</option>
201 <option value="PA">Pennsylvania</option>
202 <option value="RI">Rhode Island</option>
203 <option value="SC">South Carolina</option>
204 <option value="SD">South Dakota</option>
205 <option value="TN">Tennessee</option>
206 <option value="TX">Texas</option>
207 <option value="UT">Utah</option>
208 <option value="VT">Vermont</option>
209 <option value="VA">Virginia</option>
210 <option value="WA">Washington</option>
211 <option value="WV">West Virginia</option>
212 <option value="WI">Wisconsin</option>
213 <option value="WY">Wyoming</option>
216 <div id="transformed-combo-code-panel" style="margin-top:10px">
217 <pre id="transformed-combo-code" class="code"><code>var converted = new Ext.form.ComboBox({
219 triggerAction: 'all',
227 <b>Grid Editor</b><br />
228 <a href="../grid/edit-grid.html">Click here</a> to see the combo as a grid editor.
232 <b>Templates and Ajax</b><br />
233 <a href="forum-search.html">Click here</a> for a more advanced example.
235 <br /><br /><br /><br />