3 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
4 <title>qooxdoo
» Demo
</title>
5 <link type=
"text/css" rel=
"stylesheet" href=
"../../resource/css/layout.css"/>
7 <link type="text/css" rel="stylesheet" href="../../resource/css/layout_ie.css"/>
9 <script type=
"text/javascript" src=
"../../script/qx.js"></script>
10 <script type=
"text/javascript">
12 function getTestData() {
30 [ '17', 'Seventeen' ],
31 // Test of a long string
32 [ '1921', 'One thousand nine hundred twenty one' ]
34 for (var i
= 0; i
< testData
.length
; i
++) {
35 testData
[i
].push('widget/arrows/'+(i
% 2 ? 'up':'down')+'_small.gif');
36 testData
[i
].push('Extra data '+i
);
41 qx
.OO
.defineClass('Box', qx
.ui
.layout
.BoxLayout
, function() {
42 qx
.ui
.layout
.BoxLayout
.apply(this, arguments
);
46 qx
.OO
.defineClass('GroupBox', qx
.ui
.groupbox
.GroupBox
, function() {
47 qx
.ui
.groupbox
.GroupBox
.apply(this, arguments
);
51 qx
.core
.Init
.getInstance().defineMain(function() {
53 var form
= qx
.ui
.form
;
54 Label
= qx
.ui
.basic
.Label
;
55 var testData
= getTestData();
59 combo
= new form
.ComboBoxEx
;
60 var butSize
= new form
.Button('Size text field to content');
61 butSize
.addEventListener('execute', function() {
62 combo
.sizeTextFieldToContent();
65 var boxCombo2
= new Box
;
70 var boxCombo
= new GroupBox('This is the ComboBoxEx under test');
71 boxCombo
.add(boxCombo2
);
73 //###2nd row: Test of simple properties
74 var cEd
= new form
.CheckBox('Editable');
75 cEd
.setChecked(combo
.getEditable());
76 cEd
.addEventListener('changeChecked', function() {
77 combo
.setEditable(cEd
.isChecked());
80 var cEnsure
= new form
.CheckBox('Ensure something selected');
81 cEnsure
.setChecked(combo
.getEnsureSomethingSelected());
82 cEnsure
.addEventListener('changeChecked', function() {
83 combo
.setEnsureSomethingSelected(cEnsure
.isChecked());
86 var cAllowSearch
= new form
.CheckBox('Allow searching');
87 cAllowSearch
.setChecked(combo
.getAllowSearch());
88 cAllowSearch
.addEventListener('changeChecked', function() {
89 combo
.setAllowSearch(cAllowSearch
.isChecked());
92 var cIdCol
= new form
.CheckBox('ID column visible');
93 cIdCol
.setChecked(combo
.isIdColumnVisible());
94 cIdCol
.addEventListener('changeChecked', function() {
95 combo
.setIdColumnVisible(cIdCol
.isChecked());
98 var fieldItems
= new form
.Spinner(0, 0, testData
.length
);
99 fieldItems
._manager
.addEventListener('changeValue', function() {
100 var sel
= [], count
= fieldItems
.getValue();
101 for (var i
= 0; i
< count
; i
++) {
102 sel
.push(testData
[i
]);
104 combo
.setSelection(sel
);
106 fieldItems
.setValue(15);
108 var boxProp2
= new Box
;
111 add(cEd
, cEnsure
, cAllowSearch
, cIdCol
, new Label('Number of items in list'), fieldItems
);
113 var boxProp
= new GroupBox('Test of simple properties');
114 boxProp
.add(boxProp2
);
117 var allHeaders
= [ 'ID', 'Description', 'Img', 'Extra info' ];
118 var rb1
= new form
.RadioButton('1', '1');
119 var rb2
= new form
.RadioButton('2', '2');
120 rb2
.setChecked(true);
121 var rb3
= new form
.RadioButton('3', '3');
122 var rb4
= new form
.RadioButton('4', '4');
124 var fieldHeaders
= new qx
.manager
.selection
.RadioManager('headers', [ rb1
, rb2
, rb3
, rb4
]);
125 fieldHeaders
.addEventListener("changeSelected", function(e
) {
126 var headers
= [], count
= Number(e
.getData().getValue());
127 for (var i
= 0; i
< count
; i
++) {
128 headers
.push(allHeaders
[i
]);
130 combo
.setColumnHeaders(headers
);
133 var butChangeHeaders
= new form
.Button('Add * to headers');
134 // This tests changing the headers, but not the number of columns
135 butChangeHeaders
.addEventListener('execute', function() {
136 var headers
= combo
.getColumnHeaders();
137 for (var i
= 0; i
< headers
.length
; i
++) {
140 combo
.setColumnHeaders(headers
);
143 var boxHeaders2
= new Box
;
146 add(new Label('# of headers'), rb1
, rb2
, rb3
, rb4
, butChangeHeaders
);
148 var boxHeaders
= new GroupBox('Test headers');
149 boxHeaders
.add(boxHeaders2
);
151 var fieldMaxRows
= new form
.Spinner(2, combo
.getMaxVisibleRows(), 20);
152 fieldMaxRows
._manager
.addEventListener('changeValue', function() {
153 combo
.setMaxVisibleRows(fieldMaxRows
.getValue());
155 var boxMaxRows
= new GroupBox('Max. number of visible rows');
156 boxMaxRows
.add(fieldMaxRows
);
158 var boxRow3
= new Box
;
159 boxRow3
.add(boxHeaders
, boxMaxRows
);
161 //###Test of showOnTextField
162 var rbDesc
= new form
.RadioButton('Description', 'description');
163 rbDesc
.setChecked(true);
164 var rbIdAndDesc
= new form
.RadioButton('ID and description', 'idAndDescription');
165 var fieldShowOn
= new qx
.manager
.selection
.RadioManager("showOnTextField", [ rbDesc
, rbIdAndDesc
]);
166 fieldShowOn
.addEventListener("changeSelected", function(e
) {
167 combo
.setShowOnTextField(e
.getData().getValue());
170 var fieldSeparator
= new form
.TextField
;
171 fieldSeparator
.setValue(combo
.getIdDescriptionSeparator());
172 fieldSeparator
.setWidth(50);
173 fieldSeparator
.addEventListener('changeValue', function() {
174 combo
.setIdDescriptionSeparator(fieldSeparator
.getValue());
176 var boxShowOn2
= new Box
;
179 add(new Label('Show on text field:'), rbDesc
, rbIdAndDesc
, new Label('Separator between ID and description:'), fieldSeparator
);
181 var boxShowOn
= new GroupBox('Test showOnTextField property');
182 boxShowOn
.add(boxShowOn2
);
184 //###Test of get/setValue
185 var fieldValue
= new form
.TextField
;
186 var butSetValue
= new form
.Button('Set');
187 butSetValue
.addEventListener('execute', function() {
188 combo
.setValue(fieldValue
.getValue());
190 var butGetValue
= new form
.Button('Get');
191 butGetValue
.addEventListener('execute', function() {
192 fieldValue
.setValue(combo
.getValue());
194 var boxVal2
= new Box
;
197 add(fieldValue
, butSetValue
, butGetValue
);
199 var boxVal
= new GroupBox('Test value property');
203 var vbox
= new Box('vertical');
208 add(boxCombo
, boxProp
, boxRow3
, boxShowOn
, boxVal
);
216 <script type=
"text/javascript" src=
"../../script/layout.js"></script>
217 <script type=
"text/javascript">
219 with (qx
.dev
.log
.Logger
.ROOT_LOGGER
) {
220 removeAllAppenders();
221 addAppender(new qx
.dev
.log
.FireBugAppender
);
222 setMinLevel(qx
.dev
.log
.Logger
.LEVEL_WARN
);
226 <div id=
"demoDescription">
227 <p>ComboBoxEx is an enhanced version of ComboBox
</p>