8b3e6ccb29861b3a445bbd4b105e5b2d8b3e447c.svn-base 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  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" />
  8. <!-- GC -->
  9. <!-- LIBS -->
  10. <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
  11. <!-- ENDLIBS -->
  12. <script type="text/javascript" src="../../ext-all.js"></script>
  13. <script type="text/javascript" src="states.js"></script>
  14. <script type="text/javascript" src="combos.js"></script>
  15. <link rel="stylesheet" type="text/css" href="combos.css" />
  16. <!-- Common Styles for the examples -->
  17. <link rel="stylesheet" type="text/css" href="../examples.css" />
  18. <style type="text/css">
  19. p { width:650px; }
  20. </style>
  21. </head>
  22. <body>
  23. <script type="text/javascript" src="../examples.js"></script><!-- EXAMPLES -->
  24. <h1>Combo Boxes</h1>
  25. <p>The js is not minified so it is readable. See <a href="combos.js">combos.js</a>.</p>
  26. <p>
  27. <b>Data Sources</b><br />
  28. The combo box can use any type of Ext.data.Store as it's data source.
  29. This means your data can be XML, JSON, arrays or any other supported format. It can be loaded using Ajax, script tags or be local.
  30. This combo uses local data from a JS array:<p>
  31. <div>
  32. <input type="text" id="local-states" size="20"/>
  33. </div>
  34. <div id="state-combo-code-panel" style="margin-top:10px">
  35. <pre id="state-combo-code" class="code"><code>// simple array store
  36. var store = new Ext.data.SimpleStore({
  37. fields: ['abbr', 'state'],
  38. data : exampleData
  39. });
  40. var combo = new Ext.form.ComboBox({
  41. store: store,
  42. displayField:'state',
  43. typeAhead: true,
  44. mode: 'local',
  45. triggerAction: 'all',
  46. emptyText:'Select a state...',
  47. selectOnFocus:true,
  48. applyTo: 'local-states'
  49. });
  50. </code></pre></div>
  51. <br />
  52. <p>
  53. The combo below uses the same data, but also illustrates how to use an optional
  54. custom template to create custom UI renditions for list items. In this case,
  55. each item has a popup QuickTip which displays the state's nickname when hovered over.
  56. </p>
  57. <div>
  58. <input type="text" id="local-states-with-qtip" size="20"/>
  59. </div>
  60. <div id="state-combo-qtip-code-panel" style="margin-top:10px">
  61. <pre id="state-combo-qtip-code" class="code"><code>// simple array store
  62. var store = new Ext.data.SimpleStore({
  63. fields: ['abbr', 'state', 'nick'],
  64. data : exampleData
  65. });
  66. var comboWithTooltip = new Ext.form.ComboBox({
  67. tpl: '&lt;tpl for=".">&lt;div ext:qtip="{state}. {nick}" class="x-combo-list-item">{state}&lt;/div>&lt;/tpl>',
  68. store: store,
  69. displayField:'state',
  70. typeAhead: true,
  71. mode: 'local',
  72. triggerAction: 'all',
  73. emptyText:'Select a state...',
  74. selectOnFocus:true,
  75. applyTo: 'local-states-with-qtip'
  76. });
  77. </code></pre></div>
  78. <br />
  79. <p>
  80. <b>Unobtrusive</b><br />
  81. The combo box can very easily be used to convert existing select elements into auto-completing, filtering combos.
  82. </p>
  83. <div>
  84. Transformed select:<br/> <select name="state" id="state">
  85. <option value="AL">Alabama</option>
  86. <option value="AK">Alaska</option>
  87. <option value="AZ">Arizona</option>
  88. <option value="AR">Arkansas</option>
  89. <option value="CA">California</option>
  90. <option value="CO">Colorado</option>
  91. <option value="CT">Connecticut</option>
  92. <option value="DE">Delaware</option>
  93. <option value="FL">Florida</option>
  94. <option value="GA">Georgia</option>
  95. <option value="HI">Hawaii</option>
  96. <option value="ID">Idaho</option>
  97. <option value="IL">Illinois</option>
  98. <option value="IN">Indiana</option>
  99. <option value="IA">Iowa</option>
  100. <option value="KS">Kansas</option>
  101. <option value="KY">Kentucky</option>
  102. <option value="LA">Louisiana</option>
  103. <option value="ME">Maine</option>
  104. <option value="MD">Maryland</option>
  105. <option value="MA">Massachusetts</option>
  106. <option value="MI">Michigan</option>
  107. <option value="MN">Minnesota</option>
  108. <option value="MS">Mississippi</option>
  109. <option value="MO">Missouri</option>
  110. <option value="MT">Montana</option>
  111. <option value="NE">Nebraska</option>
  112. <option value="NV">Nevada</option>
  113. <option value="NH">New Hampshire</option>
  114. <option value="NJ">New Jersey</option>
  115. <option value="NM">New Mexico</option>
  116. <option value="NY">New York</option>
  117. <option value="NC">North Carolina</option>
  118. <option value="ND">North Dakota</option>
  119. <option value="OH" selected>Ohio</option>
  120. <option value="OK">Oklahoma</option>
  121. <option value="OR">Oregon</option>
  122. <option value="PA">Pennsylvania</option>
  123. <option value="RI">Rhode Island</option>
  124. <option value="SC">South Carolina</option>
  125. <option value="SD">South Dakota</option>
  126. <option value="TN">Tennessee</option>
  127. <option value="TX">Texas</option>
  128. <option value="UT">Utah</option>
  129. <option value="VT">Vermont</option>
  130. <option value="VA">Virginia</option>
  131. <option value="WA">Washington</option>
  132. <option value="WV">West Virginia</option>
  133. <option value="WI">Wisconsin</option>
  134. <option value="WY">Wyoming</option>
  135. </select>
  136. </div><br />
  137. <p>
  138. Originally looked like:<br/> <select name="state-orig">
  139. <option value="AL">Alabama</option>
  140. <option value="AK">Alaska</option>
  141. <option value="AZ">Arizona</option>
  142. <option value="AR">Arkansas</option>
  143. <option value="CA">California</option>
  144. <option value="CO">Colorado</option>
  145. <option value="CT">Connecticut</option>
  146. <option value="DE">Delaware</option>
  147. <option value="FL">Florida</option>
  148. <option value="GA">Georgia</option>
  149. <option value="HI">Hawaii</option>
  150. <option value="ID">Idaho</option>
  151. <option value="IL">Illinois</option>
  152. <option value="IN">Indiana</option>
  153. <option value="IA">Iowa</option>
  154. <option value="KS">Kansas</option>
  155. <option value="KY">Kentucky</option>
  156. <option value="LA">Louisiana</option>
  157. <option value="ME">Maine</option>
  158. <option value="MD">Maryland</option>
  159. <option value="MA">Massachusetts</option>
  160. <option value="MI">Michigan</option>
  161. <option value="MN">Minnesota</option>
  162. <option value="MS">Mississippi</option>
  163. <option value="MO">Missouri</option>
  164. <option value="MT">Montana</option>
  165. <option value="NE">Nebraska</option>
  166. <option value="NV">Nevada</option>
  167. <option value="NH">New Hampshire</option>
  168. <option value="NJ">New Jersey</option>
  169. <option value="NM">New Mexico</option>
  170. <option value="NY">New York</option>
  171. <option value="NC">North Carolina</option>
  172. <option value="ND">North Dakota</option>
  173. <option value="OH" selected>Ohio</option>
  174. <option value="OK">Oklahoma</option>
  175. <option value="OR">Oregon</option>
  176. <option value="PA">Pennsylvania</option>
  177. <option value="RI">Rhode Island</option>
  178. <option value="SC">South Carolina</option>
  179. <option value="SD">South Dakota</option>
  180. <option value="TN">Tennessee</option>
  181. <option value="TX">Texas</option>
  182. <option value="UT">Utah</option>
  183. <option value="VT">Vermont</option>
  184. <option value="VA">Virginia</option>
  185. <option value="WA">Washington</option>
  186. <option value="WV">West Virginia</option>
  187. <option value="WI">Wisconsin</option>
  188. <option value="WY">Wyoming</option>
  189. </select>
  190. </p>
  191. <div id="transformed-combo-code-panel" style="margin-top:10px">
  192. <pre id="transformed-combo-code" class="code"><code>var converted = new Ext.form.ComboBox({
  193. typeAhead: true,
  194. triggerAction: 'all',
  195. transform:'state',
  196. width:135,
  197. forceSelection:true
  198. });
  199. </code></pre></div>
  200. <br />
  201. <p>
  202. <b>Grid Editor</b><br />
  203. <a href="../grid/edit-grid.html">Click here</a> to see the combo as a grid editor.
  204. </p>
  205. <br />
  206. <p>
  207. <b>Templates and Ajax</b><br />
  208. <a href="forum-search.html">Click here</a> for a more advanced example.
  209. </p>
  210. <br /><br /><br /><br />
  211. </body>
  212. </html>