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         ]]
36     ];
37     /*
38      * ================  Form 2  =======================
39      */
40     mform = Roo.factory({
41         xns : Roo.form,
42         xtype : 'Form',
43         labelAlign: 'top',
44         items : [
45             {
46                 xtype : 'ComboNested',
47                 xns: Roo.form,
48                 
49                 fieldLabel: 'State',
50                 
51                 name : 'states_list',
52                 hiddenName:'states',
53                 
54                 
55                 valueField : 'abbr',
56                 displayField:'state',
57                 
58              
59                 store: {
60                     xns : Roo.data,
61                     xtype : 'SimpleStore',
62                     fields: ['abbr', 'state' , 'cn'],
63                     data : sampledata// from states.js
64                    
65                 },
66                 
67                 typeAhead: true,
68                 mode: 'local',
69                 triggerAction: 'all',
70                 emptyText:'Select a state...',
71                 selectOnFocus:true,
72                 width:190,
73                 listeners : {
74                     change: function() {
75                         Roo.log("changed to " + this.getValue());
76                         
77                     }
78                 }
79           }
80
81             
82         ]
83         
84     });
85
86     mform.render('form-ct5');
87     combo = mform.findField('states');
88    /* mform.setValues({
89         states : '["AK","AZ"]',
90         states_list : "Alaska, Arizona"
91         
92     });
93     */
94     
95     
96 });