Browse Source

Merge pull request #111391 in DEC/fineui from master to feature/x

* commit '9067f73f9fabcbd2f9ef194a82dba13b121f6ad8':
  KERNEL-12033 feat: 复选列表添加itemFormatter属性,支持自定义节点类型
es6
superman 2 years ago
parent
commit
a6dc5230f6
  1. 6
      src/widget/multiselect/multiselect.loader.js
  2. 3
      src/widget/multiselect/search/multiselect.search.insert.pane.js
  3. 8
      src/widget/multiselect/search/multiselect.search.loader.js
  4. 3
      src/widget/multiselect/search/multiselect.search.pane.js
  5. 4
      src/widget/multiselectlist/multiselectlist.insert.js

6
src/widget/multiselect/multiselect.loader.js

@ -62,7 +62,8 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, {
text: txt, text: txt,
value: v, value: v,
title: txt, title: txt,
selected: self.storeValue.type === BI.Selection.Multi selected: self.storeValue.type === BI.Selection.Multi,
...opts.itemFormatter(v),
}; };
}); });
if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) {
@ -71,7 +72,8 @@ BI.MultiSelectLoader = BI.inherit(BI.Widget, {
text: txt, text: txt,
value: startValue, value: startValue,
title: txt, title: txt,
selected: true selected: true,
...opts.itemFormatter(startValue),
}); });
} }
firstItems = self._createItems(json); firstItems = self._createItems(json);

3
src/widget/multiselect/search/multiselect.search.insert.pane.js

@ -39,6 +39,7 @@ BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, {
type: "bi.multi_select_search_loader", type: "bi.multi_select_search_loader",
keywordGetter: o.keywordGetter, keywordGetter: o.keywordGetter,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
o.itemsCreator.apply(self, [op, function (res) { o.itemsCreator.apply(self, [op, function (res) {
callback(res); callback(res);
@ -95,4 +96,4 @@ BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, {
BI.MultiSelectSearchInsertPane.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiSelectSearchInsertPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multi_select_search_insert_pane", BI.MultiSelectSearchInsertPane); BI.shortcut("bi.multi_select_search_insert_pane", BI.MultiSelectSearchInsertPane);

8
src/widget/multiselect/search/multiselect.search.loader.js

@ -12,6 +12,7 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
keywordGetter: BI.emptyFn, keywordGetter: BI.emptyFn,
valueFormatter: BI.emptyFn, valueFormatter: BI.emptyFn,
itemFormatter: BI.emptyFn,
itemHeight: 24 itemHeight: 24
}); });
}, },
@ -113,7 +114,7 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
var newValues = BI.map(values, function (i, v) { var newValues = BI.map(values, function (i, v) {
return { return {
text: o.valueFormatter(v) || v, text: o.valueFormatter(v) || v,
value: v value: v,
}; };
}); });
if (BI.isKey(keyword)) { if (BI.isKey(keyword)) {
@ -125,7 +126,8 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
text: v.text, text: v.text,
title: v.text, title: v.text,
value: v.value, value: v.value,
selected: src.type === BI.Selection.All selected: src.type === BI.Selection.All,
...o.itemFormatter(v.value),
}; };
}); });
}, },
@ -162,4 +164,4 @@ BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, {
}); });
BI.MultiSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multi_select_search_loader", BI.MultiSelectSearchLoader); BI.shortcut("bi.multi_select_search_loader", BI.MultiSelectSearchLoader);

3
src/widget/multiselect/search/multiselect.search.pane.js

@ -31,6 +31,7 @@ BI.MultiSelectSearchPane = BI.inherit(BI.Widget, {
type: "bi.multi_select_search_loader", type: "bi.multi_select_search_loader",
keywordGetter: o.keywordGetter, keywordGetter: o.keywordGetter,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
o.itemsCreator.apply(self, [op, function (res) { o.itemsCreator.apply(self, [op, function (res) {
callback(res); callback(res);
@ -82,4 +83,4 @@ BI.MultiSelectSearchPane = BI.inherit(BI.Widget, {
BI.MultiSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; BI.MultiSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE";
BI.shortcut("bi.multi_select_search_pane", BI.MultiSelectSearchPane); BI.shortcut("bi.multi_select_search_pane", BI.MultiSelectSearchPane);

4
src/widget/multiselectlist/multiselectlist.insert.js

@ -28,6 +28,7 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
itemsCreator: o.itemsCreator, itemsCreator: o.itemsCreator,
itemHeight: o.itemHeight, itemHeight: o.itemHeight,
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
logic: { logic: {
dynamic: false dynamic: false
}, },
@ -45,6 +46,7 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
type: "bi.multi_select_search_insert_pane", type: "bi.multi_select_search_insert_pane",
cls: "bi-border-left bi-border-right bi-border-bottom", cls: "bi-border-left bi-border-right bi-border-bottom",
valueFormatter: o.valueFormatter, valueFormatter: o.valueFormatter,
itemFormatter: o.itemFormatter,
keywordGetter: function () { keywordGetter: function () {
return self.trigger.getKeyword(); return self.trigger.getKeyword();
}, },
@ -240,7 +242,7 @@ BI.MultiSelectInsertList = BI.inherit(BI.Single, {
digest(); digest();
function digest () { function digest() {
BI.each(keywords, function (i, val) { BI.each(keywords, function (i, val) {
self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val); self.storeValue.type === BI.Selection.Multi ? BI.pushDistinct(self.storeValue.value, val) : BI.remove(self.storeValue.value, val);
}); });

Loading…
Cancel
Save