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