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                                                                                if(state){
98                                                                                     _this.multipleSel.list.setWidth(Math.max(_this.multipleSel.inputEl().getWidth(), _this.multipleSel.minListWidth));
99                                                                                 }
100                                                                            }
101                                                                     }
102                                                                 },
103                                                                 {
104                                                                     tabId : '#tickable',
105                                                                     xtype : 'NavItem',
106                                                                     preventDefault : true,
107                                                                     html : 'Tickable',
108                                                                     xns : Roo.bootstrap,
109                                                                     active : false,
110                                                                     listeners : {
111                                                                         render : function (_self)
112                                                                            {
113                                                                               _this.tickable = this;
114                                                                               
115                                                                            }
116                                                                     }
117                                                                 }
118                                                             ]
119
120                                                         }
121                                                     ]
122
123                                                 },
124                                                 {
125                                                     xtype : 'TabGroup',
126                                                     style : 'margin-top:20px;',
127                                                     xns : Roo.bootstrap,
128                                                     navId : '#top',
129                                                     carousel : true,
130                                                     items : [
131                                                         {
132                                                             tabId : '#normal',
133                                                             xtype : 'TabPanel',
134                                                             xns : Roo.bootstrap,
135                                                             navId : '#top',
136                                                             active : true,
137                                                             items : [
138                                                                 {
139                                                                     level : 4,
140                                                                     xtype : 'Header',
141                                                                     html : 'First TabPanel With ComboBox',
142                                                                     xns : Roo.bootstrap
143                                                                 },
144                                                                 {
145                                                                     xtype : 'Container',
146                                                                     well : 'md',
147                                                                     xns : Roo.bootstrap,
148                                                                     items : [
149                                                                         {
150                                                                             xtype : 'Row',
151                                                                             xns : Roo.bootstrap,
152                                                                             items : [
153                                                                                 {
154                                                                                     md : 12,
155                                                                                     xtype : 'Column',
156                                                                                     xns : Roo.bootstrap,
157                                                                                     items : [
158                                                                                         {
159                                                                                             xtype: 'ComboBox',
160                                                                                             xns: Roo.bootstrap,
161                                                                                             placeholder : 'Select a country',
162                                                                                             displayField : 'name',
163                                                                                             hiddenName : 'country_id',
164                                                                                             md : '12',
165                                                                                             size : 'sm',
166                                                                                             name : 'country_id_name',
167                                                                                             triggerAction : 'all',
168                                                                                             minChars : '1',
169                                                                                             tpl : '<li class="select2-result"><b>{name}</b></div>',
170                                                                                             style : 'margin-top:20px;',
171                                                                                             listeners : {
172                                                                                                 render : function (_self) {
173                                                                                                     _this.normalSel = _self;
174                                                                                                 }
175                                                                                             },
176                                                                                             forceSelection : true,
177                                                                                             valueField : 'id',
178                                                                                             queryParam : 'query[name]',
179                                                                                             editable : true,
180                                                                                             alwaysQuery : true,
181                                                                                             allowBlank : false,
182                                                                                             fieldLabel : 'Country Normal',
183                                                                                             store : {
184                                                                                                 xtype: 'Store',
185                                                                                                 xns: Roo.data,
186                                                                                                 listeners : {
187                                                                                                     beforeload : function (_self, o) {
188                                                                                                         o.params = o.params || {};
189
190                                                                                                     }
191                                                                                                 },
192                                                                                                 remoteSort : true,
193                                                                                                 sortInfo : { direction : 'ASC', field: 'name' },
194                                                                                                 proxy : {
195                                                                                                     xtype: 'HttpProxy',
196                                                                                                     xns: Roo.data,
197                                                                                                     url : baseURL + '/Geoip/Core_geoip_country',
198                                                                                                     method : 'GET'
199                                                                                                 },
200                                                                                                 reader : {
201                                                                                                     xtype: 'JsonReader',
202                                                                                                     xns: Roo.data,
203                                                                                                     fields : [
204                                                                                                         {
205                                                                                                             'name': 'id',
206                                                                                                             'type': 'int'
207                                                                                                         },
208                                                                                                         {
209                                                                                                             'name': 'code',
210                                                                                                             'type': 'string'
211                                                                                                         },
212                                                                                                         {
213                                                                                                             'name': 'name',
214                                                                                                             'type': 'string'
215                                                                                                         }
216                                                                                                     ]
217                                                                                                 }
218                                                                                             }
219                                                                                         }
220                                                                                     ]
221
222                                                                                 }
223                                                                             ]
224
225                                                                         }
226                                                                     ]
227
228                                                                 }
229                                                             ]
230
231                                                         },
232                                                         {
233                                                             tabId : '#multiple',
234                                                             xtype : 'TabPanel',
235                                                             xns : Roo.bootstrap,
236                                                             navId : '#top',
237                                                             active : false,
238                                                             items : [
239                                                                 {
240                                                                     level : 4,
241                                                                     xtype : 'Header',
242                                                                     html : 'First TabPanel With ComboBox',
243                                                                     xns : Roo.bootstrap
244                                                                 },
245                                                                 {
246                                                                     xtype : 'Container',
247                                                                     well : 'md',
248                                                                     xns : Roo.bootstrap,
249                                                                     items : [
250                                                                         {
251                                                                             xtype : 'Row',
252                                                                             xns : Roo.bootstrap,
253                                                                             items : [
254                                                                                 {
255                                                                                     md : 12,
256                                                                                     xtype : 'Column',
257                                                                                     xns : Roo.bootstrap,
258                                                                                     items : [
259                                                                                         {
260                                                                                             xtype: 'ComboBox',
261                                                                                             xns: Roo.bootstrap,
262                                                                                             placeholder : 'Select a country',
263                                                                                             displayField : 'name',
264                                                                                             hiddenName : 'country_id',
265                                                                                             md : '12',
266                                                                                             size : 'sm',
267                                                                                             name : 'country_id_name',
268                                                                                             triggerAction : 'all',
269                                                                                             minChars : '1',
270                                                                                             tpl : '<li class="select2-result"><b>{name}</b></div>',
271                                                                                             style : 'margin-top:20px;',
272                                                                                             multiple: true,
273                                                                                             listeners : {
274                                                                                                 render : function (_self) {
275                                                                                                     _this.multipleSel = _self;
276                                                                                                 }
277                                                                                             },
278                                                                                             forceSelection : true,
279                                                                                             valueField : 'id',
280                                                                                             queryParam : 'query[name]',
281                                                                                             editable : true,
282                                                                                             alwaysQuery : true,
283                                                                                             allowBlank : false,
284                                                                                             fieldLabel : 'Country Multiple',
285                                                                                             store : {
286                                                                                                 xtype: 'Store',
287                                                                                                 xns: Roo.data,
288                                                                                                 listeners : {
289                                                                                                     beforeload : function (_self, o) {
290                                                                                                         o.params = o.params || {};
291
292                                                                                                     }
293                                                                                                 },
294                                                                                                 remoteSort : true,
295                                                                                                 sortInfo : { direction : 'ASC', field: 'name' },
296                                                                                                 proxy : {
297                                                                                                     xtype: 'HttpProxy',
298                                                                                                     xns: Roo.data,
299                                                                                                     url : baseURL + '/Geoip/Core_geoip_country',
300                                                                                                     method : 'GET'
301                                                                                                 },
302                                                                                                 reader : {
303                                                                                                     xtype: 'JsonReader',
304                                                                                                     xns: Roo.data,
305                                                                                                     fields : [
306                                                                                                         {
307                                                                                                             'name': 'id',
308                                                                                                             'type': 'int'
309                                                                                                         },
310                                                                                                         {
311                                                                                                             'name': 'code',
312                                                                                                             'type': 'string'
313                                                                                                         },
314                                                                                                         {
315                                                                                                             'name': 'name',
316                                                                                                             'type': 'string'
317                                                                                                         }
318                                                                                                     ]
319                                                                                                 }
320                                                                                             }
321                                                                                         }
322                                                                                     ]
323
324                                                                                 }
325                                                                             ]
326
327                                                                         }
328                                                                     ]
329
330                                                                 }
331                                                             ]
332
333                                                         },
334                                                         {
335                                                             tabId : '#tickable',
336                                                             xtype : 'TabPanel',
337                                                             xns : Roo.bootstrap,
338                                                             navId : '#top',
339                                                             active : false,
340                                                             items : [
341                                                                 {
342                                                                     level : 4,
343                                                                     xtype : 'Header',
344                                                                     html : 'Second TabPanel With ComboBox',
345                                                                     xns : Roo.bootstrap
346                                                                 },
347                                                                 {
348                                                                     xtype : 'Container',
349                                                                     well : 'md',
350                                                                     xns : Roo.bootstrap,
351                                                                     items : [
352                                                                         {
353                                                                             xtype : 'Row',
354                                                                             xns : Roo.bootstrap,
355                                                                             items : [
356                                                                                 {
357                                                                                     xtype: 'ComboBox',
358                                                                                     xns: Roo.bootstrap,
359                                                                                     placeholder : 'Select a country',
360                                                                                     displayField : 'name',
361                                                                                     hiddenName : 'country_id',
362                                                                                     md : '12',
363                                                                                     size : 'sm',
364                                                                                     name : 'country_id_name',
365                                                                                     triggerAction : 'all',
366                                                                                     minChars : '1',
367                                                                 //                    tpl : '<li class="select2-result"><b>{name}</b></div>',
368                                                                                     style : 'margin-top:20px;',
369                                                                                     multiple: true,
370                                                                                     tickable: true,
371                                                                                     listeners : {
372                                                                                         render : function (_self) {
373                                                                                             _this.tickableSel = _self;
374                                                                                         }
375                                                                                     },
376                                                                                     forceSelection : true,
377                                                                                     valueField : 'id',
378                                                                                     queryParam : 'query[name]',
379                                                                                     editable : true,
380                                                                                     alwaysQuery : true,
381                                                                                     allowBlank : false,
382                                                                                     fieldLabel : 'Country With Tickable',
383                                                                                     store : {
384                                                                                         xtype: 'Store',
385                                                                                         xns: Roo.data,
386                                                                                         listeners : {
387                                                                                             beforeload : function (_self, o) {
388                                                                                                 o.params = o.params || {};
389
390                                                                                             }
391                                                                                         },
392                                                                                         remoteSort : true,
393                                                                                         sortInfo : { direction : 'ASC', field: 'name' },
394                                                                                         proxy : {
395                                                                                             xtype: 'HttpProxy',
396                                                                                             xns: Roo.data,
397                                                                                             url : baseURL + '/Geoip/Core_geoip_country',
398                                                                                             method : 'GET'
399                                                                                         },
400                                                                                         reader : {
401                                                                                             xtype: 'JsonReader',
402                                                                                             xns: Roo.data,
403                                                                                             fields : [
404                                                                                                 {
405                                                                                                     'name': 'id',
406                                                                                                     'type': 'int'
407                                                                                                 },
408                                                                                                 {
409                                                                                                     'name': 'code',
410                                                                                                     'type': 'string'
411                                                                                                 },
412                                                                                                 {
413                                                                                                     'name': 'name',
414                                                                                                     'type': 'string'
415                                                                                                 }
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 });