3 * Copyright(c) 2008-2011 Alan Knowles
10 * @class Roo.form.ComboCheck
11 * @extends Roo.form.ComboBox
12 * A combobox for multiple select items.
14 * Create a new ComboCheck
15 * @param {Object} config Configuration options
17 Roo.form.ComboCheck = function(config){
18 Roo.form.ComboCheck.superclass.constructor.call(this, config);
19 // should verify some data...
21 // hiddenName = required..
22 // displayField = required
23 // valudField == required
24 var req= [ 'hiddenName', 'displayField', 'valueField' ];
26 Roo.each(req, function(e) {
27 if ((typeof(_t[e]) == 'undefined' ) || !_t[e].length) {
28 throw "Roo.form.ComboCheck : missing value for: " + e;
35 Roo.extend(Roo.form.ComboCheck, Roo.form.ComboBox, {
43 onRender : function(ct, position){
49 var cls = 'x-combo-list';
52 this.tpl = new Roo.Template({
53 html : '<div class="'+cls+'-item x-menu-check-item{' + this.valueField + ':this.checked}">' +
54 '<img class="x-menu-item-icon" style="margin: 0px;" src="' + Roo.BLANK_IMAGE_URL + '">' +
55 '<span>{' + this.displayField + '}</span>' +
57 checked: function (value, allValues) {
58 var ar = _t.getValueArray();
59 return ar.indexOf(value) > -1 ? ' x-menu-item-checked' : ''
65 Roo.form.ComboCheck.superclass.onRender.call(this, ct, position);
66 this.view.singleSelect = false;
69 onSelect : function(record, index){
70 if(this.fireEvent('beforeselect', this, record, index) !== false){
73 this.setFromData(index > -1 ? record.data : false);
75 var = this.view.getSelectedIndexes();
78 this.fireEvent('select', this, record, index);
81 getValueArray : function()
85 var ret = Roo.decode(thist.getValue());
86 ret = typeof(ar) == 'Array' ? ar : []; //?? valid?
89 Roo.log("Roo.form.ComboCheck:getValueArray invalid data:" + _t.getValue());