examples/form/nestedcombo.js
[roojs1] / examples / form / nestedcombo.js
1 /*
2  * 
3  * (C) Alan Knowles 2011
4  * Licence : Roojs - LGPL
5  */
6  
7 var mform;
8 var combo
9 Roo.onReady(function(){
10
11     Roo.QuickTips.init();
12
13       sampledata  = [
14         ['A', 'A states', [
15             ['AK', 'Alaska'],
16             ['AZ', 'Arizona'],
17             ['AR', 'Arkansas']
18                            
19         ]],
20         ['C', 'C states', [        
21           ['CA', 'California'],
22             ['CO', 'Colorado'],
23             ['CT', 'Connecticut']
24         ]],
25         ['D', 'D states', [
26             ['DE', 'Delaware'],
27             ['DC', 'District of Columbia']
28         ]],
29         ['I', 'I states', [
30         
31             ['ID', 'Idaho'],
32             ['IL', 'Illinois'],
33             ['IN', 'Indiana'],
34             ['IA', 'Iowa'],
35             ['IDA', 'Idaho'],
36             ['ILA', 'Illinois'],
37             ['INA', 'Indiana'],
38             ['IAA', 'Iowa']
39         ]]
40     ];
41     /*
42      * ================  Form 2  =======================
43      */
44     mform = Roo.factory({
45         xns : Roo.form,
46         xtype : 'Form',
47         labelAlign: 'top',
48         items : [
49             {
50                 xtype : 'ComboNested',
51                 xns: Roo.form,
52                 
53                 fieldLabel: 'State',
54                 
55                 name : 'states_list',
56                 hiddenName:'states',
57                 
58                 
59                 valueField : 'abbr',
60                 displayField:'state',
61                 
62              
63                 store: {
64                     xns : Roo.data,
65                     xtype : 'SimpleStore',
66                     fields: ['abbr', 'state' , 'cn'],
67                     data : sampledata// from states.js
68                    
69                 },
70                 listWidth: 300,
71                 typeAhead: true,
72                 mode: 'local',
73                 triggerAction: 'all',
74                 emptyText:'Select a state...',
75                 selectOnFocus:true,
76                 width:190,
77                 listeners : {
78                     change: function() {
79                         Roo.log("changed to " + this.getValue());
80                         
81                     }
82                 }
83           }
84
85             
86         ]
87         
88     });
89
90     mform.render('form-ct5');
91     combo = mform.findField('states');
92    /* mform.setValues({
93         states : '["AK","AZ"]',
94         states_list : "Alaska, Arizona"
95         
96     });
97     */
98     
99     
100 });