BoundList2.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-view-BoundList'>/**
  19. </span> * An internally used DataView for {@link Ext.form.field.ComboBox ComboBox}.
  20. */
  21. Ext.define('Ext.view.BoundList', {
  22. extend: 'Ext.view.View',
  23. alias: 'widget.boundlist',
  24. alternateClassName: 'Ext.BoundList',
  25. requires: ['Ext.layout.component.BoundList', 'Ext.toolbar.Paging'],
  26. <span id='Ext-view-BoundList-cfg-pageSize'> /**
  27. </span> * @cfg {Number} [pageSize=0]
  28. * If greater than `0`, a {@link Ext.toolbar.Paging} is displayed at the bottom of the list and store
  29. * queries will execute with page {@link Ext.data.Operation#start start} and
  30. * {@link Ext.data.Operation#limit limit} parameters.
  31. */
  32. pageSize: 0,
  33. <span id='Ext-view-BoundList-cfg-displayField'> /**
  34. </span> * @cfg {String} [displayField=&quot;&quot;]
  35. * The field from the store to show in the view.
  36. */
  37. <span id='Ext-view-BoundList-property-pagingToolbar'> /**
  38. </span> * @property {Ext.toolbar.Paging} pagingToolbar
  39. * A reference to the PagingToolbar instance in this view. Only populated if {@link #pageSize} is greater
  40. * than zero and the BoundList has been rendered.
  41. */
  42. // private overrides
  43. baseCls: Ext.baseCSSPrefix + 'boundlist',
  44. itemCls: Ext.baseCSSPrefix + 'boundlist-item',
  45. listItemCls: '',
  46. shadow: false,
  47. trackOver: true,
  48. refreshed: 0,
  49. // This Component is used as a popup, not part of a complex layout. Display data immediately.
  50. deferInitialRefresh: false,
  51. componentLayout: 'boundlist',
  52. childEls: [
  53. 'listEl'
  54. ],
  55. renderTpl: [
  56. '&lt;div id=&quot;{id}-listEl&quot; class=&quot;{baseCls}-list-ct&quot; style=&quot;overflow:auto&quot;&gt;&lt;/div&gt;',
  57. '{%',
  58. 'var me=values.$comp, pagingToolbar=me.pagingToolbar;',
  59. 'if (pagingToolbar) {',
  60. 'pagingToolbar.ownerLayout = me.componentLayout;',
  61. 'Ext.DomHelper.generateMarkup(pagingToolbar.getRenderTree(), out);',
  62. '}',
  63. '%}',
  64. {
  65. disableFormats: true
  66. }
  67. ],
  68. <span id='Ext-view-BoundList-cfg-tpl'> /**
  69. </span> * @cfg {String/Ext.XTemplate} tpl
  70. * A String or Ext.XTemplate instance to apply to inner template.
  71. *
  72. * {@link Ext.view.BoundList} is used for the dropdown list of {@link Ext.form.field.ComboBox}.
  73. * To customize the template you can do this:
  74. *
  75. * Ext.create('Ext.form.field.ComboBox', {
  76. * fieldLabel : 'State',
  77. * queryMode : 'local',
  78. * displayField : 'text',
  79. * valueField : 'abbr',
  80. * store : Ext.create('StateStore', {
  81. * fields : ['abbr', 'text'],
  82. * data : [
  83. * {&quot;abbr&quot;:&quot;AL&quot;, &quot;name&quot;:&quot;Alabama&quot;},
  84. * {&quot;abbr&quot;:&quot;AK&quot;, &quot;name&quot;:&quot;Alaska&quot;},
  85. * {&quot;abbr&quot;:&quot;AZ&quot;, &quot;name&quot;:&quot;Arizona&quot;}
  86. * //...
  87. * ]
  88. * }),
  89. * listConfig : {
  90. * tpl : '&lt;tpl for=&quot;.&quot;&gt;&lt;div class=&quot;x-boundlist-item&quot;&gt;{abbr}&lt;/div&gt;&lt;/tpl&gt;'
  91. * }
  92. * });
  93. *
  94. * Defaults to:
  95. *
  96. * Ext.create('Ext.XTemplate',
  97. * '&lt;ul&gt;&lt;tpl for=&quot;.&quot;&gt;',
  98. * '&lt;li role=&quot;option&quot; class=&quot;' + itemCls + '&quot;&gt;' + me.getInnerTpl(me.displayField) + '&lt;/li&gt;',
  99. * '&lt;/tpl&gt;&lt;/ul&gt;'
  100. * );
  101. *
  102. */
  103. initComponent: function() {
  104. var me = this,
  105. baseCls = me.baseCls,
  106. itemCls = me.itemCls;
  107. me.selectedItemCls = baseCls + '-selected';
  108. me.overItemCls = baseCls + '-item-over';
  109. me.itemSelector = &quot;.&quot; + itemCls;
  110. if (me.floating) {
  111. me.addCls(baseCls + '-floating');
  112. }
  113. if (!me.tpl) {
  114. // should be setting aria-posinset based on entire set of data
  115. // not filtered set
  116. me.tpl = new Ext.XTemplate(
  117. '&lt;ul&gt;&lt;tpl for=&quot;.&quot;&gt;',
  118. '&lt;li role=&quot;option&quot; class=&quot;' + itemCls + '&quot;&gt;' + me.getInnerTpl(me.displayField) + '&lt;/li&gt;',
  119. '&lt;/tpl&gt;&lt;/ul&gt;'
  120. );
  121. } else if (Ext.isString(me.tpl)) {
  122. me.tpl = new Ext.XTemplate(me.tpl);
  123. }
  124. if (me.pageSize) {
  125. me.pagingToolbar = me.createPagingToolbar();
  126. }
  127. me.callParent();
  128. },
  129. beforeRender: function() {
  130. var me = this;
  131. me.callParent(arguments);
  132. // If there's a Menu among our ancestors, then add the menu class.
  133. // This is so that the MenuManager does not see a mousedown in this Component as a document mousedown, outside the Menu
  134. if (me.up('menu')) {
  135. me.addCls(Ext.baseCSSPrefix + 'menu');
  136. }
  137. },
  138. <span id='Ext-view-BoundList-method-getBubbleTarget'> /**
  139. </span> * @private
  140. * Boundlist-specific implementation of the getBubbleTarget used by {@link Ext.AbstractComponent#up} method.
  141. * This links to the owning input field so that the FocusManager, when receiving notification of a hide event,
  142. * can find a focusable parent.
  143. */
  144. getBubbleTarget: function() {
  145. return this.pickerField;
  146. },
  147. getRefItems: function() {
  148. return this.pagingToolbar ? [ this.pagingToolbar ] : [];
  149. },
  150. createPagingToolbar: function() {
  151. return Ext.widget('pagingtoolbar', {
  152. id: this.id + '-paging-toolbar',
  153. pageSize: this.pageSize,
  154. store: this.store,
  155. border: false,
  156. ownerCt: this,
  157. ownerLayout: this.getComponentLayout()
  158. });
  159. },
  160. // Do the job of a container layout at this point even though we are not a Container.
  161. // TODO: Refactor as a Container.
  162. finishRenderChildren: function () {
  163. var toolbar = this.pagingToolbar;
  164. this.callParent(arguments);
  165. if (toolbar) {
  166. toolbar.finishRender();
  167. }
  168. },
  169. refresh: function(){
  170. var me = this,
  171. toolbar = me.pagingToolbar;
  172. me.callParent();
  173. // The view removes the targetEl from the DOM before updating the template
  174. // Ensure the toolbar goes to the end
  175. if (me.rendered &amp;&amp; toolbar &amp;&amp; toolbar.rendered &amp;&amp; !me.preserveScrollOnRefresh) {
  176. me.el.appendChild(toolbar.el);
  177. }
  178. },
  179. bindStore : function(store, initial) {
  180. var toolbar = this.pagingToolbar;
  181. this.callParent(arguments);
  182. if (toolbar) {
  183. toolbar.bindStore(this.store, initial);
  184. }
  185. },
  186. getTargetEl: function() {
  187. return this.listEl || this.el;
  188. },
  189. <span id='Ext-view-BoundList-method-getInnerTpl'> /**
  190. </span> * A method that returns the inner template for displaying items in the list.
  191. * This method is useful to override when using a more complex display value, for example
  192. * inserting an icon along with the text.
  193. * @param {String} displayField The {@link #displayField} for the BoundList.
  194. * @return {String} The inner template
  195. */
  196. getInnerTpl: function(displayField) {
  197. return '{' + displayField + '}';
  198. },
  199. onDestroy: function() {
  200. Ext.destroyMembers(this, 'pagingToolbar', 'listEl');
  201. this.callParent();
  202. }
  203. });
  204. </pre>
  205. </body>
  206. </html>