diff --git a/demo/js/case/combo/demo.text_value_down_list_combo.js b/demo/js/case/combo/demo.text_value_down_list_combo.js index 51a8c1a4c5..7368ead340 100644 --- a/demo/js/case/combo/demo.text_value_down_list_combo.js +++ b/demo/js/case/combo/demo.text_value_down_list_combo.js @@ -41,9 +41,18 @@ Demo.TextValueDownListCombo = BI.inherit(BI.Widget, { type: "bi.button", width: 90, height: 25, + text: "setValue", handler: function () { self.refs.setValue(2); } + }, { + type: "bi.button", + width: 90, + height: 25, + text: "getValue", + handler: function () { + BI.Msg.alert("", JSON.stringify(self.refs.getValue())); + } }], vgap: 20 }; diff --git a/demo/js/case/combo/demo.text_vlaue_check_combo.js b/demo/js/case/combo/demo.text_vlaue_check_combo.js index 0d017f80d3..607a060c96 100644 --- a/demo/js/case/combo/demo.text_vlaue_check_combo.js +++ b/demo/js/case/combo/demo.text_vlaue_check_combo.js @@ -6,13 +6,16 @@ Demo.TextValueCheckCombo = BI.inherit(BI.Widget, { baseCls: "" }, render: function () { - + var self = this; return { type: "bi.horizontal_auto", items: [{ type: "bi.text_value_check_combo", + ref: function () { + self.combo = this; + }, text: "默认值", - value: 1, + //value: 1, width: 300, items: [{ text: "MVC-1", @@ -24,6 +27,13 @@ Demo.TextValueCheckCombo = BI.inherit(BI.Widget, { text: "MVC-3", value: 3 }] + }, { + type: "bi.button", + width: 90, + height: 25, + handler: function () { + BI.Msg.alert("", JSON.stringify(self.combo.getValue())); + } }], vgap: 20 }; diff --git a/dist/bundle.js b/dist/bundle.js index 58041d7f5e..febdd979ef 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -67585,7 +67585,8 @@ BI.IconCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.iconCombo.getValue(); + var value = this.iconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -67686,7 +67687,8 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { } this.button = BI.createWidget(o.el, { type: "bi.icon_change_button", - cls: "icon-combo-trigger-icon " + iconCls, + cls: "icon-combo-trigger-icon", + iconCls: iconCls, disableSelected: true, width: o.width, height: o.height, @@ -67783,7 +67785,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }); this.popup = BI.createWidget({ type: "bi.icon_text_value_combo_popup", - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); @@ -67813,7 +67816,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -67844,7 +67848,8 @@ BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { @@ -67944,7 +67949,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.combo.getValue(); + var value = this.combo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); } }); BI.StaticCombo.EVENT_CHANGE = "EVENT_CHANGE"; @@ -68017,7 +68023,8 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCheckCombo.getValue(); + var value = this.textIconCheckCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -68210,7 +68217,8 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -80391,23 +80399,35 @@ BI.DownListPopup = BI.inherit(BI.Pane, { }, _checkValues: function (values) { - var self = this; + var self = this, o = this.options; var value = []; - BI.each(this.options.items, function (idx, itemGroup) { + BI.each(o.items, function (idx, itemGroup) { BI.each(itemGroup, function (id, item) { if(BI.isNotNull(item.children)){ var childValues = BI.pluck(item.children, "value"); - if(BI.contains(childValues, values[idx])){ - value.push(values[idx]); + if(BI.contains(childValues, valueGetter(idx))){ + value.push(valueGetter(idx)); } }else{ - if(item.value === values[idx]){ - value.push(values[idx]); + if(item.value === valueGetter(idx)){ + value.push(valueGetter(idx)); } } }) }); return value; + + function valueGetter(index) { + switch (o.chooseType) { + case BI.Selection.Single: + return values[0]; + break; + case BI.Selection.Multi: + return values[index]; + default: + break; + } + } }, populate: function (items) { diff --git a/dist/case.js b/dist/case.js index 0c36f02d07..5b09100de1 100644 --- a/dist/case.js +++ b/dist/case.js @@ -5291,7 +5291,8 @@ BI.IconCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.iconCombo.getValue(); + var value = this.iconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -5392,7 +5393,8 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { } this.button = BI.createWidget(o.el, { type: "bi.icon_change_button", - cls: "icon-combo-trigger-icon " + iconCls, + cls: "icon-combo-trigger-icon", + iconCls: iconCls, disableSelected: true, width: o.width, height: o.height, @@ -5489,7 +5491,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }); this.popup = BI.createWidget({ type: "bi.icon_text_value_combo_popup", - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); @@ -5519,7 +5522,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -5550,7 +5554,8 @@ BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { @@ -5650,7 +5655,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.combo.getValue(); + var value = this.combo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); } }); BI.StaticCombo.EVENT_CHANGE = "EVENT_CHANGE"; @@ -5723,7 +5729,8 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCheckCombo.getValue(); + var value = this.textIconCheckCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -5916,7 +5923,8 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { diff --git a/dist/demo.js b/dist/demo.js index 5c75e6a27c..703f3292c6 100644 --- a/dist/demo.js +++ b/dist/demo.js @@ -1997,9 +1997,18 @@ Demo.TextValueDownListCombo = BI.inherit(BI.Widget, { type: "bi.button", width: 90, height: 25, + text: "setValue", handler: function () { self.refs.setValue(2); } + }, { + type: "bi.button", + width: 90, + height: 25, + text: "getValue", + handler: function () { + BI.Msg.alert("", JSON.stringify(self.refs.getValue())); + } }], vgap: 20 }; @@ -2014,13 +2023,16 @@ Demo.TextValueCheckCombo = BI.inherit(BI.Widget, { baseCls: "" }, render: function () { - + var self = this; return { type: "bi.horizontal_auto", items: [{ type: "bi.text_value_check_combo", + ref: function () { + self.combo = this; + }, text: "默认值", - value: 1, + //value: 1, width: 300, items: [{ text: "MVC-1", @@ -2032,6 +2044,13 @@ Demo.TextValueCheckCombo = BI.inherit(BI.Widget, { text: "MVC-3", value: 3 }] + }, { + type: "bi.button", + width: 90, + height: 25, + handler: function () { + BI.Msg.alert("", JSON.stringify(self.combo.getValue())); + } }], vgap: 20 }; diff --git a/dist/fineui.js b/dist/fineui.js index 84fc13e89c..e831391a3d 100644 --- a/dist/fineui.js +++ b/dist/fineui.js @@ -69279,7 +69279,8 @@ BI.IconCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.iconCombo.getValue(); + var value = this.iconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -69380,7 +69381,8 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { } this.button = BI.createWidget(o.el, { type: "bi.icon_change_button", - cls: "icon-combo-trigger-icon " + iconCls, + cls: "icon-combo-trigger-icon", + iconCls: iconCls, disableSelected: true, width: o.width, height: o.height, @@ -69477,7 +69479,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }); this.popup = BI.createWidget({ type: "bi.icon_text_value_combo_popup", - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); @@ -69507,7 +69510,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -69538,7 +69542,8 @@ BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { @@ -69638,7 +69643,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.combo.getValue(); + var value = this.combo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); } }); BI.StaticCombo.EVENT_CHANGE = "EVENT_CHANGE"; @@ -69711,7 +69717,8 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCheckCombo.getValue(); + var value = this.textIconCheckCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -69904,7 +69911,8 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { @@ -82085,23 +82093,35 @@ BI.DownListPopup = BI.inherit(BI.Pane, { }, _checkValues: function (values) { - var self = this; + var self = this, o = this.options; var value = []; - BI.each(this.options.items, function (idx, itemGroup) { + BI.each(o.items, function (idx, itemGroup) { BI.each(itemGroup, function (id, item) { if(BI.isNotNull(item.children)){ var childValues = BI.pluck(item.children, "value"); - if(BI.contains(childValues, values[idx])){ - value.push(values[idx]); + if(BI.contains(childValues, valueGetter(idx))){ + value.push(valueGetter(idx)); } }else{ - if(item.value === values[idx]){ - value.push(values[idx]); + if(item.value === valueGetter(idx)){ + value.push(valueGetter(idx)); } } }) }); return value; + + function valueGetter(index) { + switch (o.chooseType) { + case BI.Selection.Single: + return values[0]; + break; + case BI.Selection.Multi: + return values[index]; + default: + break; + } + } }, populate: function (items) { diff --git a/dist/widget.js b/dist/widget.js index 34b5989dac..5323085927 100644 --- a/dist/widget.js +++ b/dist/widget.js @@ -3977,23 +3977,35 @@ BI.DownListPopup = BI.inherit(BI.Pane, { }, _checkValues: function (values) { - var self = this; + var self = this, o = this.options; var value = []; - BI.each(this.options.items, function (idx, itemGroup) { + BI.each(o.items, function (idx, itemGroup) { BI.each(itemGroup, function (id, item) { if(BI.isNotNull(item.children)){ var childValues = BI.pluck(item.children, "value"); - if(BI.contains(childValues, values[idx])){ - value.push(values[idx]); + if(BI.contains(childValues, valueGetter(idx))){ + value.push(valueGetter(idx)); } }else{ - if(item.value === values[idx]){ - value.push(values[idx]); + if(item.value === valueGetter(idx)){ + value.push(valueGetter(idx)); } } }) }); return value; + + function valueGetter(index) { + switch (o.chooseType) { + case BI.Selection.Single: + return values[0]; + break; + case BI.Selection.Multi: + return values[index]; + default: + break; + } + } }, populate: function (items) { diff --git a/src/case/combo/iconcombo/combo.icon.js b/src/case/combo/iconcombo/combo.icon.js index 39799527f8..cea1e89b9c 100644 --- a/src/case/combo/iconcombo/combo.icon.js +++ b/src/case/combo/iconcombo/combo.icon.js @@ -85,7 +85,8 @@ BI.IconCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.iconCombo.getValue(); + var value = this.iconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { diff --git a/src/case/combo/iconcombo/trigger.iconcombo.js b/src/case/combo/iconcombo/trigger.iconcombo.js index 0f3f7d6357..71c3bbb869 100644 --- a/src/case/combo/iconcombo/trigger.iconcombo.js +++ b/src/case/combo/iconcombo/trigger.iconcombo.js @@ -27,7 +27,8 @@ BI.IconComboTrigger = BI.inherit(BI.Trigger, { } this.button = BI.createWidget(o.el, { type: "bi.icon_change_button", - cls: "icon-combo-trigger-icon " + iconCls, + cls: "icon-combo-trigger-icon", + iconCls: iconCls, disableSelected: true, width: o.width, height: o.height, diff --git a/src/case/combo/icontextvaluecombo/combo.icontextvalue.js b/src/case/combo/icontextvaluecombo/combo.icontextvalue.js index ecf4be7ca1..2b317ed385 100644 --- a/src/case/combo/icontextvaluecombo/combo.icontextvalue.js +++ b/src/case/combo/icontextvaluecombo/combo.icontextvalue.js @@ -24,7 +24,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }); this.popup = BI.createWidget({ type: "bi.icon_text_value_combo_popup", - items: o.items + items: o.items, + value: o.value }); this.popup.on(BI.IconTextValueComboPopup.EVENT_CHANGE, function () { self.setValue(self.popup.getValue()); @@ -54,7 +55,8 @@ BI.IconTextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { diff --git a/src/case/combo/icontextvaluecombo/popup.icontextvalue.js b/src/case/combo/icontextvaluecombo/popup.icontextvalue.js index 2f1c30537c..f9a6b65071 100644 --- a/src/case/combo/icontextvaluecombo/popup.icontextvalue.js +++ b/src/case/combo/icontextvaluecombo/popup.icontextvalue.js @@ -20,7 +20,8 @@ BI.IconTextValueComboPopup = BI.inherit(BI.Pane, { chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, layouts: [{ type: "bi.vertical" - }] + }], + value: o.value }); this.popup.on(BI.Controller.EVENT_CHANGE, function (type, val, obj) { diff --git a/src/case/combo/staticcombo/combo.static.js b/src/case/combo/staticcombo/combo.static.js index 95d3505148..e7599b71c7 100644 --- a/src/case/combo/staticcombo/combo.static.js +++ b/src/case/combo/staticcombo/combo.static.js @@ -62,7 +62,8 @@ BI.StaticCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.combo.getValue(); + var value = this.combo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); } }); BI.StaticCombo.EVENT_CHANGE = "EVENT_CHANGE"; diff --git a/src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js b/src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js index 7550fda40f..be1434eaa2 100644 --- a/src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js +++ b/src/case/combo/textvaluecheckcombo/combo.textvaluecheck.js @@ -67,7 +67,8 @@ BI.TextValueCheckCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCheckCombo.getValue(); + var value = this.textIconCheckCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { diff --git a/src/case/combo/textvaluecombo/combo.textvalue.js b/src/case/combo/textvaluecombo/combo.textvalue.js index 9470090874..812a7fda62 100644 --- a/src/case/combo/textvaluecombo/combo.textvalue.js +++ b/src/case/combo/textvaluecombo/combo.textvalue.js @@ -57,7 +57,8 @@ BI.TextValueCombo = BI.inherit(BI.Widget, { }, getValue: function () { - return this.textIconCombo.getValue(); + var value = this.textIconCombo.getValue(); + return BI.isNull(value) ? [] : (BI.isArray(value) ? value : [value]); }, populate: function (items) { diff --git a/src/widget/downlist/popup.downlist.js b/src/widget/downlist/popup.downlist.js index e0d984e570..4bacae9b99 100644 --- a/src/widget/downlist/popup.downlist.js +++ b/src/widget/downlist/popup.downlist.js @@ -194,23 +194,35 @@ BI.DownListPopup = BI.inherit(BI.Pane, { }, _checkValues: function (values) { - var self = this; + var self = this, o = this.options; var value = []; - BI.each(this.options.items, function (idx, itemGroup) { + BI.each(o.items, function (idx, itemGroup) { BI.each(itemGroup, function (id, item) { if(BI.isNotNull(item.children)){ var childValues = BI.pluck(item.children, "value"); - if(BI.contains(childValues, values[idx])){ - value.push(values[idx]); + if(BI.contains(childValues, valueGetter(idx))){ + value.push(valueGetter(idx)); } }else{ - if(item.value === values[idx]){ - value.push(values[idx]); + if(item.value === valueGetter(idx)){ + value.push(valueGetter(idx)); } } }) }); return value; + + function valueGetter(index) { + switch (o.chooseType) { + case BI.Selection.Single: + return values[0]; + break; + case BI.Selection.Multi: + return values[index]; + default: + break; + } + } }, populate: function (items) {