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