examples/bootstrap/ComboBox.js
[roojs1] / examples / bootstrap / ComboBox.js
1
2
3 Roo.example = Roo.example || {};
4
5 Roo.example.combobox = 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: 'ComboBox',
32                     xns: Roo.bootstrap,
33                     placeholder : 'Select a country',
34                     displayField : 'name',
35                     hiddenName : 'country_id',
36                     md : '12',
37                     size : 'sm',
38                     name : 'country_id_name',
39                     triggerAction : 'all',
40                     minChars : '2',
41                     tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b></div>',
42                     listWidth : '400',
43                     listeners : {
44                         render : function (_self) {
45                             _this.countrySel = _self;
46                         }
47                     },
48                     forceSelection : true,
49                     valueField : 'id',
50                     queryParam : 'query[name]',
51                     editable : true,
52                     alwaysQuery : true,
53                     allowBlank : false,
54                     fieldLabel : 'Country',
55                     pageSize : '20',
56                     append: true,
57                     store : {
58                         xtype: 'Store',
59                         xns: Roo.data,
60                         listeners : {
61                             beforeload : function (_self, o) {
62                                 o.params = o.params || {};
63                             }
64                         },
65                         proxy : {
66                             xtype: 'HttpProxy',
67                             xns: Roo.data,
68                             url : baseURL + '/Roo/Core_geoip_country',
69                             method : 'GET'
70                         },
71                         reader : {
72                             xtype: 'JsonReader',
73                             xns: Roo.data,
74                             fields : [
75                                 {
76                                     'name': 'id',
77                                     'type': 'int'
78                                 },
79                                 {
80                                     'name': 'code',
81                                     'type': 'string'
82                                 },
83                                 {
84                                     'name': 'name',
85                                     'type': 'string'
86                                 }
87                             ]
88                         }
89                     }
90                 }
91             ]
92         };
93     }
94 });