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                                                                     }
95                                                                 },
96                                                                 {
97                                                                     tabId : '#tickable',
98                                                                     xtype : 'NavItem',
99                                                                     preventDefault : true,
100                                                                     html : 'Tickable',
101                                                                     xns : Roo.bootstrap,
102                                                                     active : false,
103                                                                     listeners : {
104                                                                         render : function (_self)
105                                                                            {
106                                                                               _this.tickable = this;
107                                                                               
108                                                                            }
109                                                                     }
110                                                                 }
111                                                             ]
112
113                                                         }
114                                                     ]
115
116                                                 },
117                                                 {
118                                                     xtype : 'TabGroup',
119                                                     style : 'margin-top:20px;',
120                                                     xns : Roo.bootstrap,
121                                                     navId : '#top',
122                                                     carousel : true,
123                                                     items : [
124                                                         {
125                                                             tabId : '#normal',
126                                                             xtype : 'TabPanel',
127                                                             xns : Roo.bootstrap,
128                                                             navId : '#top',
129                                                             active : true,
130                                                             items : [
131                                                                 {
132                                                                     level : 4,
133                                                                     xtype : 'Header',
134                                                                     html : 'First TabPanel With ComboBox',
135                                                                     xns : Roo.bootstrap
136                                                                 },
137                                                                 {
138                                                                     xtype : 'Container',
139                                                                     well : 'md',
140                                                                     xns : Roo.bootstrap,
141                                                                     items : [
142                                                                         {
143                                                                             xtype : 'Row',
144                                                                             xns : Roo.bootstrap,
145                                                                             items : [
146                                                                                 {
147                                                                                     md : 12,
148                                                                                     xtype : 'Column',
149                                                                                     xns : Roo.bootstrap,
150                                                                                     items : [
151                                                                                         {
152                                                                                             xtype: 'ComboBox',
153                                                                                             xns: Roo.bootstrap,
154                                                                                             placeholder : 'Select a country',
155                                                                                             displayField : 'title',
156                                                                                             hiddenName : 'country_id',
157                                                                                             md : '12',
158                                                                                             size : 'sm',
159                                                                                             name : 'country_id_name',
160                                                                                             triggerAction : 'all',
161                                                                                             minChars : '1',
162                                                                                             tpl : '<li class="roo-select2-result"><b>{title}</b></div>',
163                                                                                             style : 'margin-top:20px;',
164                                                                                             listeners : {
165                                                                                                 render : function (_self) {
166                                                                                                     _this.normalSel = _self;
167                                                                                                 }
168                                                                                             },
169                                                                                             forceSelection : true,
170                                                                                             valueField : 'id',
171                                                                                             queryParam : 'query[name]',
172                                                                                             editable : true,
173                                                                                             alwaysQuery : true,
174                                                                                             allowBlank : false,
175                                                                                             fieldLabel : 'Country Normal',
176                                                                                             store : {
177                                                                                                 xtype: 'Store',
178                                                                                                 xns: Roo.data,
179                                                                                                 listeners : {
180                                                                                                     beforeload : function (_self, o) {
181                                                                                                         o.params = o.params || {};
182
183                                                                                                     }
184                                                                                                 },
185                                                                                                 remoteSort : true,
186                                                                                                 sortInfo : { direction : 'ASC', field: 'title' },
187                                                                                                 proxy : {
188                                                                                                     xtype: 'HttpProxy',
189                                                                                                     xns: Roo.data,
190                                                                                                     url : './data.country.js',
191                                                                                                     method : 'GET'
192                                                                                                 },
193                                                                                                 reader : {
194                                                                                                     xtype: 'JsonReader',
195                                                                                                     xns: Roo.data,
196                                                                                                     fields : [
197                                                                                                         {
198                                                                                                             'name': 'id',
199                                                                                                             'type': 'int'
200                                                                                                         },
201                                                                                                         {
202                                                                                                             'name': 'code',
203                                                                                                             'type': 'string'
204                                                                                                         },
205                                                                                                         {
206                                                                                                             'name': 'title',
207                                                                                                             'type': 'string'
208                                                                                                         }
209                                                                                                     ]
210                                                                                                 }
211                                                                                             }
212                                                                                         }
213                                                                                     ]
214
215                                                                                 }
216                                                                             ]
217
218                                                                         }
219                                                                     ]
220
221                                                                 }
222                                                             ]
223
224                                                         },
225                                                         {
226                                                             tabId : '#multiple',
227                                                             xtype : 'TabPanel',
228                                                             xns : Roo.bootstrap,
229                                                             navId : '#top',
230                                                             active : false,
231                                                             listeners : {
232                                                                    changed : function (_self, state)
233                                                                    {
234                                                                        if(state){
235                                                                             _this.multipleSel.list.setWidth(Math.max(_this.multipleSel.inputEl().getWidth(), _this.multipleSel.minListWidth));
236                                                                         }
237                                                                    }
238                                                             },
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 : 'title',
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="roo-select2-result"><b>{title}</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 : false,
296                                                                                                 sortInfo : { direction : 'ASC', field: 'title' },
297                                                                                                 proxy : {
298                                                                                                     xtype: 'HttpProxy',
299                                                                                                     xns: Roo.data,
300                                                                                                     url : './data.country.js',
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': 'title',
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                                                             listeners : {
342                                                                    changed : function (_self, state)
343                                                                    {
344                                                                        if(state){
345                                                                             _this.tickableSel.list.setWidth(Math.max(_this.tickableSel.inputEl().getWidth(), _this.tickableSel.minListWidth));
346                                                                         }
347                                                                    }
348                                                             },
349                                                             items : [
350                                                                 {
351                                                                     level : 4,
352                                                                     xtype : 'Header',
353                                                                     html : 'Second TabPanel With ComboBox',
354                                                                     xns : Roo.bootstrap
355                                                                 },
356                                                                 {
357                                                                     xtype : 'Container',
358                                                                     well : 'md',
359                                                                     xns : Roo.bootstrap,
360                                                                     items : [
361                                                                         {
362                                                                             xtype : 'Row',
363                                                                             xns : Roo.bootstrap,
364                                                                             items : [
365                                                                                 {
366                                                                                     xtype: 'ComboBox',
367                                                                                     xns: Roo.bootstrap,
368                                                                                     placeholder : 'Select a country',
369                                                                                     displayField : 'title',
370                                                                                     hiddenName : 'country_id',
371                                                                                     md : '12',
372                                                                                     size : 'sm',
373                                                                                     name : 'country_id_name',
374                                                                                     triggerAction : 'all',
375                                                                                     minChars : '1',
376                                                                 //                    tpl : '<li class="roo-select2-result"><b>{name}</b></div>',
377                                                                                     style : 'margin-top:20px;',
378                                                                                     multiple: true,
379                                                                                     tickable: true,
380                                                                                     listeners : {
381                                                                                         render : function (_self) {
382                                                                                             _this.tickableSel = _self;
383                                                                                         }
384                                                                                     },
385                                                                                     forceSelection : true,
386                                                                                     valueField : 'id',
387                                                                                     queryParam : 'query[name]',
388                                                                                     editable : true,
389                                                                                     alwaysQuery : true,
390                                                                                     allowBlank : false,
391                                                                                     fieldLabel : 'Country With Tickable',
392                                                                                     store : {
393                                                                                         xtype: 'Store',
394                                                                                         xns: Roo.data,
395                                                                                         listeners : {
396                                                                                             beforeload : function (_self, o) {
397                                                                                                 o.params = o.params || {};
398
399                                                                                             }
400                                                                                         },
401                                                                                         remoteSort : false,
402                                                                                         sortInfo : { direction : 'ASC', field: 'title' },
403                                                                                         proxy : {
404                                                                                             xtype: 'HttpProxy',
405                                                                                             xns: Roo.data,
406                                                                                             url : '../bootstrap/data.country.js',
407                                                                                             method : 'GET'
408                                                                                         },
409                                                                                         reader : {
410                                                                                             xtype: 'JsonReader',
411                                                                                             xns: Roo.data,
412                                                                                             fields : [
413                                                                                                 {
414                                                                                                     'name': 'id',
415                                                                                                     'type': 'int'
416                                                                                                 },
417                                                                                                 {
418                                                                                                     'name': 'code',
419                                                                                                     'type': 'string'
420                                                                                                 },
421                                                                                                 {
422                                                                                                     'name': 'title',
423                                                                                                     'type': 'string'
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
449                         }
450                     ]
451
452                 }
453             ]
454         };
455     }
456 });