Browse Source

Pull request #3098: KERNEL-12250 feat:简化一下combolist的api

Merge in VISUAL/fineui from ~TREECAT/fineui:master to master

* commit '8efb8ba0e84da26b555e832243fdc40a7b7c6708':
  KERNEL-12250 feat:简化一下combolist的api
es6
treecat-罗群 2 years ago
parent
commit
3cf6e2640c
  1. 6
      demo/js/widget/downlist/demo.downlist.js
  2. 31
      src/widget/downlist/combo.downlist.js

6
demo/js/widget/downlist/demo.downlist.js

@ -47,11 +47,9 @@ Demo.Downlist = BI.inherit(BI.Widget, {
width: 100,
items: [
[{
el: {
text: "column 1111",
iconCls1: "dot-e-font",
value: 12
},
value: 12,
children: [{
text: "column 1.1",
value: 21,
@ -166,13 +164,11 @@ Demo.Downlist = BI.inherit(BI.Widget, {
}],
items: [
[{
el: {
text: "选项一",
value: 1,
icon: {
type: "demo.downlist.icon",
},
},
children: [{
text: "选项一",
value: 11,

31
src/widget/downlist/combo.downlist.js

@ -1,3 +1,31 @@
(function() {
function transformItems(items) {
if (!items) return items;
var result = BI.cloneDeep(items);
var isComplexItmes = BI.some(items, function (_, item) {
return BI.isArray(item);
});
// 传一维数组,帮转二维
if (!isComplexItmes) {
result = [result];
}
// 帮转 el
BI.each(result, function (_, arr) {
BI.each(arr, function (_, item) {
if (item.children && !item.el) {
item.el = {
text: item.text,
icon: item.icon,
cls: item.cls,
iconCls1: item.iconCls1,
value: item.value
};
}
});
});
return result;
}
/**
* Created by roy on 15/8/14.
*/
@ -47,7 +75,7 @@ BI.DownListCombo = BI.inherit(BI.Widget, {
ref: function (ref) {
self.popupView = ref;
},
items: o.items,
items: transformItems(o.items),
chooseType: o.chooseType,
value: o.value,
listeners: [{
@ -108,3 +136,4 @@ BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE";
BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW";
BI.shortcut("bi.down_list_combo", BI.DownListCombo);
}());

Loading…
Cancel
Save