examples/bootstrap/TabPanel-ComboBox.js
[roojs1] / examples / bootstrap / TabPanel-ComboBox.js
1
2
3 Roo.example = Roo.example || {};
4
5 Roo.example.TabPanelCombobox = new Roo.XComponent({
6     part     :  ["layout","viewpanel"],
7     order    : '001-viewpanel',
8     region   : '',
9     parent   : '#bootstrap',
10     name     : "unnamed module",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         
16         this.parent = {
17             el : new Roo.bootstrap.Body()
18         }
19         this.parent.el.layout = false;
20         this.parent.el.render(document.body);
21         
22         var _this = this;
23         var MODULE = this;
24         var baseURL = '/web.eventmanager/demo.local.php';
25         
26         return {
27             xtype: 'Body',
28             xns: Roo.bootstrap,
29             items : [
30                  {
31                     xtype : 'Container',
32                     cls : 'content',
33                     xns : Roo.bootstrap,
34                     style : 'margin-top:100px',
35                     items : [
36                         {
37                             xtype : 'Container',
38                             cls : 'pad-wrapper',
39                             xns : Roo.bootstrap,
40                             items : [
41                                 {
42                                     xtype : 'Container',
43                                     cls : 'container alpha',
44                                     xns : Roo.bootstrap,
45                                     items : [
46                                         {
47                                             xtype : 'Container',
48                                             xns : Roo.bootstrap,
49                                             items : [
50                                                 {
51                                                     xtype : 'NavSimplebar',
52                                                     xns : Roo.bootstrap,
53                                                     items : [
54                                                         {
55                                                             navId : '#top',
56                                                             xtype : 'NavGroup',
57                                                             xns : Roo.bootstrap,
58                                                             type : 'pills',
59                                                             listeners : {
60                                                                 render : function (_self)
61                                                                    {
62                                                                         _this.navGroup = this;
63                                                                    }
64                                                             },
65                                                             items : [
66                                                                 {
67                                                                     tabId : '#normal',
68                                                                     xtype : 'NavItem',
69                                                                     preventDefault : true,
70                                                                     html : 'Normal',
71                                                                     xns : Roo.bootstrap,
72                                                                     active : true,
73                                                                     listeners : {
74                                                                         render : function (_self)
75                                                                            {
76                                                                               _this.normal = this;
77                                                                               
78                                                                            }
79                                                                     }
80                                                                 },
81                                                                 {
82                                                                     tabId : '#multiple',
83                                                                     xtype : 'NavItem',
84                                                                     preventDefault : true,
85                                                                     html : 'Multiple',
86                                                                     xns : Roo.bootstrap,
87                                                                     active : false,
88                                                                     listeners : {
89                                                                         render : function (_self)
90                                                                            {
91                                                                               _this.multiple = this;
92                                                                               
93                                                                            },
94                                                                            changed : function (_self, state)
95                                                                            {
96                                                                                Roo.log('chnaged???');
97                                                                                Roo.log(this.multipleSel.inputEl().getWidth());
98                                                                                if(state){
99                                                                                     _this.multipleSel.list.setWidth(Math.max(_this.multipleSel.inputEl().getWidth(), _this.multipleSel.minListWidth));
100                                                                                 }
101                                                                            }
102                                                                     }
103                                                                 },
104                                                                 {
105                                                                     tabId : '#tickable',
106                                                                     xtype : 'NavItem',
107                                                                     preventDefault : true,
108                                                                     html : 'Tickable',
109                                                                     xns : Roo.bootstrap,
110                                                                     active : false,
111                                                                     listeners : {
112                                                                         render : function (_self)
113                                                                            {
114                                                                               _this.tickable = this;
115                                                                               
116                                                                            }
117                                                                     }
118                                                                 }
119                                                             ]
120
121                                                         }
122                                                     ]
123
124                                                 },
125                                                 {
126                                                     xtype : 'TabGroup',
127                                                     style : 'margin-top:20px;',
128                                                     xns : Roo.bootstrap,
129                                                     navId : '#top',
130                                                     carousel : true,
131                                                     items : [
132                                                         {
133                                                             tabId : '#normal',
134                                                             xtype : 'TabPanel',
135                                                             xns : Roo.bootstrap,
136                                                             navId : '#top',
137                                                             active : true,
138                                                             items : [
139                                                                 {
140                                                                     level : 4,
141                                                                     xtype : 'Header',
142                                                                     html : 'First TabPanel With ComboBox',
143                                                                     xns : Roo.bootstrap
144                                                                 },
145                                                                 {
146                                                                     xtype : 'Container',
147                                                                     well : 'md',
148                                                                     xns : Roo.bootstrap,
149                                                                     items : [
150                                                                         {
151                                                                             xtype : 'Row',
152                                                                             xns : Roo.bootstrap,
153                                                                             items : [
154                                                                                 {
155                                                                                     md : 12,
156                                                                                     xtype : 'Column',
157                                                                                     xns : Roo.bootstrap,
158                                                                                     items : [
159                                                                                         {
160                                                                                             xtype: 'ComboBox',
161                                                                                             xns: Roo.bootstrap,
162                                                                                             placeholder : 'Select a country',
163                                                                                             displayField : 'name',
164                                                                                             hiddenName : 'country_id',
165                                                                                             md : '12',
166                                                                                             size : 'sm',
167                                                                                             name : 'country_id_name',
168                                                                                             triggerAction : 'all',
169                                                                                             minChars : '1',
170                                                                                             tpl : '<li class="select2-result"><b>{name}</b></div>',
171                                                                                             style : 'margin-top:20px;',
172                                                                                             listeners : {
173                                                                                                 render : function (_self) {
174                                                                                                     _this.normalSel = _self;
175                                                                                                 }
176                                                                                             },
177                                                                                             forceSelection : true,
178                                                                                             valueField : 'id',
179                                                                                             queryParam : 'query[name]',
180                                                                                             editable : true,
181                                                                                             alwaysQuery : true,
182                                                                                             allowBlank : false,
183                                                                                             fieldLabel : 'Country Normal',
184                                                                                             store : {
185                                                                                                 xtype: 'Store',
186                                                                                                 xns: Roo.data,
187                                                                                                 listeners : {
188                                                                                                     beforeload : function (_self, o) {
189                                                                                                         o.params = o.params || {};
190
191                                                                                                     }
192                                                                                                 },
193                                                                                                 remoteSort : true,
194                                                                                                 sortInfo : { direction : 'ASC', field: 'name' },
195                                                                                                 proxy : {
196                                                                                                     xtype: 'HttpProxy',
197                                                                                                     xns: Roo.data,
198                                                                                                     url : baseURL + '/Geoip/Core_geoip_country',
199                                                                                                     method : 'GET'
200                                                                                                 },
201                                                                                                 reader : {
202                                                                                                     xtype: 'JsonReader',
203                                                                                                     xns: Roo.data,
204                                                                                                     fields : [
205                                                                                                         {
206                                                                                                             'name': 'id',
207                                                                                                             'type': 'int'
208                                                                                                         },
209                                                                                                         {
210                                                                                                             'name': 'code',
211                                                                                                             'type': 'string'
212                                                                                                         },
213                                                                                                         {
214                                                                                                             'name': 'name',
215                                                                                                             'type': 'string'
216                                                                                                         }
217                                                                                                     ]
218                                                                                                 }
219                                                                                             }
220                                                                                         }
221                                                                                     ]
222
223                                                                                 }
224                                                                             ]
225
226                                                                         }
227                                                                     ]
228
229                                                                 }
230                                                             ]
231
232                                                         },
233                                                         {
234                                                             tabId : '#multiple',
235                                                             xtype : 'TabPanel',
236                                                             xns : Roo.bootstrap,
237                                                             navId : '#top',
238                                                             active : false,
239                                                             items : [
240                                                                 {
241                                                                     level : 4,
242                                                                     xtype : 'Header',
243                                                                     html : 'First TabPanel With ComboBox',
244                                                                     xns : Roo.bootstrap
245                                                                 },
246                                                                 {
247                                                                     xtype : 'Container',
248                                                                     well : 'md',
249                                                                     xns : Roo.bootstrap,
250                                                                     items : [
251                                                                         {
252                                                                             xtype : 'Row',
253                                                                             xns : Roo.bootstrap,
254                                                                             items : [
255                                                                                 {
256                                                                                     md : 12,
257                                                                                     xtype : 'Column',
258                                                                                     xns : Roo.bootstrap,
259                                                                                     items : [
260                                                                                         {
261                                                                                             xtype: 'ComboBox',
262                                                                                             xns: Roo.bootstrap,
263                                                                                             placeholder : 'Select a country',
264                                                                                             displayField : 'name',
265                                                                                             hiddenName : 'country_id',
266                                                                                             md : '12',
267                                                                                             size : 'sm',
268                                                                                             name : 'country_id_name',
269                                                                                             triggerAction : 'all',
270                                                                                             minChars : '1',
271                                                                                             tpl : '<li class="select2-result"><b>{name}</b></div>',
272                                                                                             style : 'margin-top:20px;',
273                                                                                             multiple: true,
274                                                                                             listeners : {
275                                                                                                 render : function (_self) {
276                                                                                                     _this.multipleSel = _self;
277                                                                                                 }
278                                                                                             },
279                                                                                             forceSelection : true,
280                                                                                             valueField : 'id',
281                                                                                             queryParam : 'query[name]',
282                                                                                             editable : true,
283                                                                                             alwaysQuery : true,
284                                                                                             allowBlank : false,
285                                                                                             fieldLabel : 'Country Multiple',
286                                                                                             store : {
287                                                                                                 xtype: 'Store',
288                                                                                                 xns: Roo.data,
289                                                                                                 listeners : {
290                                                                                                     beforeload : function (_self, o) {
291                                                                                                         o.params = o.params || {};
292
293                                                                                                     }
294                                                                                                 },
295                                                                                                 remoteSort : true,
296                                                                                                 sortInfo : { direction : 'ASC', field: 'name' },
297                                                                                                 proxy : {
298                                                                                                     xtype: 'HttpProxy',
299                                                                                                     xns: Roo.data,
300                                                                                                     url : baseURL + '/Geoip/Core_geoip_country',
301                                                                                                     method : 'GET'
302                                                                                                 },
303                                                                                                 reader : {
304                                                                                                     xtype: 'JsonReader',
305                                                                                                     xns: Roo.data,
306                                                                                                     fields : [
307                                                                                                         {
308                                                                                                             'name': 'id',
309                                                                                                             'type': 'int'
310                                                                                                         },
311                                                                                                         {
312                                                                                                             'name': 'code',
313                                                                                                             'type': 'string'
314                                                                                                         },
315                                                                                                         {
316                                                                                                             'name': 'name',
317                                                                                                             'type': 'string'
318                                                                                                         }
319                                                                                                     ]
320                                                                                                 }
321                                                                                             }
322                                                                                         }
323                                                                                     ]
324
325                                                                                 }
326                                                                             ]
327
328                                                                         }
329                                                                     ]
330
331                                                                 }
332                                                             ]
333
334                                                         },
335                                                         {
336                                                             tabId : '#tickable',
337                                                             xtype : 'TabPanel',
338                                                             xns : Roo.bootstrap,
339                                                             navId : '#top',
340                                                             active : false,
341                                                             items : [
342                                                                 {
343                                                                     level : 4,
344                                                                     xtype : 'Header',
345                                                                     html : 'Second TabPanel With ComboBox',
346                                                                     xns : Roo.bootstrap
347                                                                 },
348                                                                 {
349                                                                     xtype : 'Container',
350                                                                     well : 'md',
351                                                                     xns : Roo.bootstrap,
352                                                                     items : [
353                                                                         {
354                                                                             xtype : 'Row',
355                                                                             xns : Roo.bootstrap,
356                                                                             items : [
357                                                                                 {
358                                                                                     xtype: 'ComboBox',
359                                                                                     xns: Roo.bootstrap,
360                                                                                     placeholder : 'Select a country',
361                                                                                     displayField : 'name',
362                                                                                     hiddenName : 'country_id',
363                                                                                     md : '12',
364                                                                                     size : 'sm',
365                                                                                     name : 'country_id_name',
366                                                                                     triggerAction : 'all',
367                                                                                     minChars : '1',
368                                                                 //                    tpl : '<li class="select2-result"><b>{name}</b></div>',
369                                                                                     style : 'margin-top:20px;',
370                                                                                     multiple: true,
371                                                                                     tickable: true,
372                                                                                     listeners : {
373                                                                                         render : function (_self) {
374                                                                                             _this.tickableSel = _self;
375                                                                                         }
376                                                                                     },
377                                                                                     forceSelection : true,
378                                                                                     valueField : 'id',
379                                                                                     queryParam : 'query[name]',
380                                                                                     editable : true,
381                                                                                     alwaysQuery : true,
382                                                                                     allowBlank : false,
383                                                                                     fieldLabel : 'Country With Tickable',
384                                                                                     store : {
385                                                                                         xtype: 'Store',
386                                                                                         xns: Roo.data,
387                                                                                         listeners : {
388                                                                                             beforeload : function (_self, o) {
389                                                                                                 o.params = o.params || {};
390
391                                                                                             }
392                                                                                         },
393                                                                                         remoteSort : true,
394                                                                                         sortInfo : { direction : 'ASC', field: 'name' },
395                                                                                         proxy : {
396                                                                                             xtype: 'HttpProxy',
397                                                                                             xns: Roo.data,
398                                                                                             url : baseURL + '/Geoip/Core_geoip_country',
399                                                                                             method : 'GET'
400                                                                                         },
401                                                                                         reader : {
402                                                                                             xtype: 'JsonReader',
403                                                                                             xns: Roo.data,
404                                                                                             fields : [
405                                                                                                 {
406                                                                                                     'name': 'id',
407                                                                                                     'type': 'int'
408                                                                                                 },
409                                                                                                 {
410                                                                                                     'name': 'code',
411                                                                                                     'type': 'string'
412                                                                                                 },
413                                                                                                 {
414                                                                                                     'name': 'name',
415                                                                                                     'type': 'string'
416                                                                                                 }
417                                                                                             ]
418                                                                                         }
419                                                                                     }
420                                                                                 }
421                                                                             ]
422
423                                                                         }
424                                                                     ]
425
426                                                                 }
427                                                             ]
428
429                                                         }
430                                                     ]
431
432                                                 }
433                                             ]
434
435                                         }
436                                     ]
437
438                                 }
439                             ]
440
441                         }
442                     ]
443
444                 }
445             ]
446         };
447     }
448 });