examples/bootstrap/ComboBox2.js
[roojs1] / examples / bootstrap / ComboBox2.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 : '1',
41                     tpl : '<li class="select2-result"><b>{name}</b></div>',
42                     listWidth : '400',
43                     style : 'margin-top:20px;',
44                     multiple: true,
45                     listeners : {
46                         render : function (_self) {
47                             _this.countrySel = _self;
48                         }
49                     },
50                     forceSelection : true,
51                     valueField : 'id',
52                     queryParam : 'query[name]',
53                     editable : true,
54                     alwaysQuery : true,
55                     allowBlank : false,
56                     fieldLabel : 'Country Normal',
57                     pageSize : '10',
58                     append: true,
59                     store : {
60                         xtype: 'Store',
61                         xns: Roo.data,
62                         listeners : {
63                             beforeload : function (_self, o) {
64                                 o.params = o.params || {};
65                                 
66                                 var selected = _this.countrySel.getValue();
67                                 
68                                 if(selected.length){
69                                     o.params._skip = selected;
70                                 }
71                                 
72                             }
73                         },
74                         remoteSort : true,
75                         sortInfo : { direction : 'ASC', field: 'name' },
76                         proxy : {
77                             xtype: 'HttpProxy',
78                             xns: Roo.data,
79                             url : baseURL + '/Geoip/Core_geoip_country',
80                             method : 'GET'
81                         },
82                         reader : {
83                             xtype: 'JsonReader',
84                             xns: Roo.data,
85                             fields : [
86                                 {
87                                     'name': 'id',
88                                     'type': 'int'
89                                 },
90                                 {
91                                     'name': 'code',
92                                     'type': 'string'
93                                 },
94                                 {
95                                     'name': 'name',
96                                     'type': 'string'
97                                 }
98                             ]
99                         }
100                     }
101                 },
102                 {
103                     xtype: 'ComboBox',
104                     xns: Roo.bootstrap,
105                     placeholder : 'Select a country',
106                     displayField : 'name',
107                     hiddenName : 'country_id',
108                     md : '12',
109                     size : 'sm',
110                     name : 'country_id_name',
111                     triggerAction : 'all',
112                     minChars : '1',
113                     tpl : '<li class="select2-result"><b>{name}</b></div>',
114                     listWidth : '400',
115                     multiple: true,
116                     listeners : {
117                         render : function (_self) {
118                             _this.countrySel = _self;
119                         }
120                     },
121                     forceSelection : true,
122                     valueField : 'id',
123                     queryParam : 'query[name]',
124                     editable : true,
125                     alwaysQuery : true,
126                     allowBlank : false,
127                     fieldLabel : 'Country With CheckBox',
128                     pageSize : '10',
129                     append: true,
130                     store : {
131                         xtype: 'Store',
132                         xns: Roo.data,
133                         listeners : {
134                             beforeload : function (_self, o) {
135                                 o.params = o.params || {};
136                                 
137                                 var selected = _this.countrySel.getValue();
138                                 
139                                 if(selected.length){
140                                     o.params._skip = selected;
141                                 }
142                                 
143                             }
144                         },
145                         remoteSort : true,
146                         sortInfo : { direction : 'ASC', field: 'name' },
147                         proxy : {
148                             xtype: 'HttpProxy',
149                             xns: Roo.data,
150                             url : baseURL + '/Geoip/Core_geoip_country',
151                             method : 'GET'
152                         },
153                         reader : {
154                             xtype: 'JsonReader',
155                             xns: Roo.data,
156                             fields : [
157                                 {
158                                     'name': 'id',
159                                     'type': 'int'
160                                 },
161                                 {
162                                     'name': 'code',
163                                     'type': 'string'
164                                 },
165                                 {
166                                     'name': 'name',
167                                     'type': 'string'
168                                 }
169                             ]
170                         }
171                     }
172                 }
173             ]
174         };
175     }
176 });