Browse Source

复选下拉树加formatter,下拉框的默认formatter

es6
Frank.Qiu 7 years ago
parent
commit
9b02716b04
  1. 4
      demo/config.js
  2. 30
      dist/bundle.js
  3. 4
      dist/demo.js
  4. 30
      dist/widget.js
  5. 3
      src/component/allvaluechooser/abstract.allvaluechooser.js
  6. 13
      src/component/treevaluechooser/abstract.treevaluechooser.js
  7. 1
      src/component/treevaluechooser/combo.treevaluechooser.js
  8. 3
      src/component/valuechooser/abstract.valuechooser.js
  9. 2
      src/widget/multitree/multi.tree.combo.js
  10. 8
      src/widget/multitree/trigger/searcher.multi.tree.js

4
demo/config.js

File diff suppressed because one or more lines are too long

30
dist/bundle.js vendored

@ -99478,6 +99478,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multi-tree-combo", baseCls: "bi-multi-tree-combo",
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
height: 25 height: 25
}); });
}, },
@ -99495,6 +99496,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: "bi.multi_select_trigger", type: "bi.multi_select_trigger",
height: o.height, height: o.height,
valueFormatter: o.valueFormatter,
// adapter: this.popup, // adapter: this.popup,
masker: { masker: {
offset: this.constants.offset offset: this.constants.offset
@ -99973,6 +99975,9 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multi-tree-searcher", baseCls: "bi-multi-tree-searcher",
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
valueFormatter: function (v) {
return v;
},
popup: {}, popup: {},
adapter: null, adapter: null,
@ -100068,6 +100073,7 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
}, },
setState: function (ob) { setState: function (ob) {
var o = this.options;
ob || (ob = {}); ob || (ob = {});
ob.value || (ob.value = {}); ob.value || (ob.value = {});
if (BI.isNumber(ob)) { if (BI.isNumber(ob)) {
@ -100078,7 +100084,7 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
var text = ""; var text = "";
BI.each(ob.value, function (name, children) { BI.each(ob.value, function (name, children) {
var childNodes = getChildrenNode(children); var childNodes = getChildrenNode(children);
text += name + (childNodes === "" ? "" : (":" + childNodes)) + "; "; text += (o.valueFormatter(name + "") || name) + (childNodes === "" ? "" : (":" + childNodes)) + "; ";
}); });
this.editor.setState(text); this.editor.setState(text);
} }
@ -100089,7 +100095,7 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
BI.each(ob, function (name, children) { BI.each(ob, function (name, children) {
index++; index++;
var childNodes = getChildrenNode(children); var childNodes = getChildrenNode(children);
text += name + (childNodes === "" ? "" : (":" + childNodes)) + (index === size ? "" : ","); text += (o.valueFormatter(name + "") || name) + (childNodes === "" ? "" : (":" + childNodes)) + (index === size ? "" : ",");
}); });
return text; return text;
} }
@ -109790,7 +109796,8 @@ BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
var text = v; var text = v;
if (BI.isNotNull(this.items)) { if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) { BI.some(this.items, function (i, item) {
if (item.value === v) { // 把value都换成字符串
if (item.value + "" === v) {
text = item.text; text = item.text;
return true; return true;
} }
@ -109979,6 +109986,19 @@ BI.shortcut("bi.all_value_chooser_pane", BI.AllValueChooserPane);BI.AbstractTree
}); });
}, },
_valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) {
if (item.value + "" === v) {
text = item.text;
return true;
}
});
}
return text;
},
_initData: function (items) { _initData: function (items) {
this.items = items; this.items = items;
var nodes = BI.Tree.treeFormat(items); var nodes = BI.Tree.treeFormat(items);
@ -110652,6 +110672,7 @@ BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
type: "bi.multi_tree_combo", type: "bi.multi_tree_combo",
element: this, element: this,
itemsCreator: BI.bind(this._itemsCreator, this), itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width, width: o.width,
height: o.height height: o.height
}); });
@ -110752,7 +110773,8 @@ BI.AbstractValueChooser = BI.inherit(BI.Widget, {
var text = v; var text = v;
if (BI.isNotNull(this.items)) { if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) { BI.some(this.items, function (i, item) {
if (item.value === v) { // 把value都换成字符串
if (item.value + "" === v) {
text = item.text; text = item.text;
return true; return true;
} }

4
dist/demo.js vendored

File diff suppressed because one or more lines are too long

30
dist/widget.js vendored

@ -12843,6 +12843,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multi-tree-combo", baseCls: "bi-multi-tree-combo",
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
height: 25 height: 25
}); });
}, },
@ -12860,6 +12861,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: "bi.multi_select_trigger", type: "bi.multi_select_trigger",
height: o.height, height: o.height,
valueFormatter: o.valueFormatter,
// adapter: this.popup, // adapter: this.popup,
masker: { masker: {
offset: this.constants.offset offset: this.constants.offset
@ -13338,6 +13340,9 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multi-tree-searcher", baseCls: "bi-multi-tree-searcher",
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
valueFormatter: function (v) {
return v;
},
popup: {}, popup: {},
adapter: null, adapter: null,
@ -13433,6 +13438,7 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
}, },
setState: function (ob) { setState: function (ob) {
var o = this.options;
ob || (ob = {}); ob || (ob = {});
ob.value || (ob.value = {}); ob.value || (ob.value = {});
if (BI.isNumber(ob)) { if (BI.isNumber(ob)) {
@ -13443,7 +13449,7 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
var text = ""; var text = "";
BI.each(ob.value, function (name, children) { BI.each(ob.value, function (name, children) {
var childNodes = getChildrenNode(children); var childNodes = getChildrenNode(children);
text += name + (childNodes === "" ? "" : (":" + childNodes)) + "; "; text += (o.valueFormatter(name + "") || name) + (childNodes === "" ? "" : (":" + childNodes)) + "; ";
}); });
this.editor.setState(text); this.editor.setState(text);
} }
@ -13454,7 +13460,7 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
BI.each(ob, function (name, children) { BI.each(ob, function (name, children) {
index++; index++;
var childNodes = getChildrenNode(children); var childNodes = getChildrenNode(children);
text += name + (childNodes === "" ? "" : (":" + childNodes)) + (index === size ? "" : ","); text += (o.valueFormatter(name + "") || name) + (childNodes === "" ? "" : (":" + childNodes)) + (index === size ? "" : ",");
}); });
return text; return text;
} }
@ -23155,7 +23161,8 @@ BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
var text = v; var text = v;
if (BI.isNotNull(this.items)) { if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) { BI.some(this.items, function (i, item) {
if (item.value === v) { // 把value都换成字符串
if (item.value + "" === v) {
text = item.text; text = item.text;
return true; return true;
} }
@ -23344,6 +23351,19 @@ BI.shortcut("bi.all_value_chooser_pane", BI.AllValueChooserPane);BI.AbstractTree
}); });
}, },
_valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) {
if (item.value + "" === v) {
text = item.text;
return true;
}
});
}
return text;
},
_initData: function (items) { _initData: function (items) {
this.items = items; this.items = items;
var nodes = BI.Tree.treeFormat(items); var nodes = BI.Tree.treeFormat(items);
@ -24017,6 +24037,7 @@ BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
type: "bi.multi_tree_combo", type: "bi.multi_tree_combo",
element: this, element: this,
itemsCreator: BI.bind(this._itemsCreator, this), itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width, width: o.width,
height: o.height height: o.height
}); });
@ -24117,7 +24138,8 @@ BI.AbstractValueChooser = BI.inherit(BI.Widget, {
var text = v; var text = v;
if (BI.isNotNull(this.items)) { if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) { BI.some(this.items, function (i, item) {
if (item.value === v) { // 把value都换成字符串
if (item.value + "" === v) {
text = item.text; text = item.text;
return true; return true;
} }

3
src/component/allvaluechooser/abstract.allvaluechooser.js

@ -26,7 +26,8 @@ BI.AbstractAllValueChooser = BI.inherit(BI.Widget, {
var text = v; var text = v;
if (BI.isNotNull(this.items)) { if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) { BI.some(this.items, function (i, item) {
if (item.value === v) { // 把value都换成字符串
if (item.value + "" === v) {
text = item.text; text = item.text;
return true; return true;
} }

13
src/component/treevaluechooser/abstract.treevaluechooser.js

@ -11,6 +11,19 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
}); });
}, },
_valueFormatter: function (v) {
var text = v;
if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) {
if (item.value + "" === v) {
text = item.text;
return true;
}
});
}
return text;
},
_initData: function (items) { _initData: function (items) {
this.items = items; this.items = items;
var nodes = BI.Tree.treeFormat(items); var nodes = BI.Tree.treeFormat(items);

1
src/component/treevaluechooser/combo.treevaluechooser.js

@ -27,6 +27,7 @@ BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, {
type: "bi.multi_tree_combo", type: "bi.multi_tree_combo",
element: this, element: this,
itemsCreator: BI.bind(this._itemsCreator, this), itemsCreator: BI.bind(this._itemsCreator, this),
valueFormatter: BI.bind(this._valueFormatter, this),
width: o.width, width: o.width,
height: o.height height: o.height
}); });

3
src/component/valuechooser/abstract.valuechooser.js

@ -24,7 +24,8 @@ BI.AbstractValueChooser = BI.inherit(BI.Widget, {
var text = v; var text = v;
if (BI.isNotNull(this.items)) { if (BI.isNotNull(this.items)) {
BI.some(this.items, function (i, item) { BI.some(this.items, function (i, item) {
if (item.value === v) { // 把value都换成字符串
if (item.value + "" === v) {
text = item.text; text = item.text;
return true; return true;
} }

2
src/widget/multitree/multi.tree.combo.js

@ -19,6 +19,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multi-tree-combo", baseCls: "bi-multi-tree-combo",
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
valueFormatter: BI.emptyFn,
height: 25 height: 25
}); });
}, },
@ -36,6 +37,7 @@ BI.MultiTreeCombo = BI.inherit(BI.Single, {
this.trigger = BI.createWidget({ this.trigger = BI.createWidget({
type: "bi.multi_select_trigger", type: "bi.multi_select_trigger",
height: o.height, height: o.height,
valueFormatter: o.valueFormatter,
// adapter: this.popup, // adapter: this.popup,
masker: { masker: {
offset: this.constants.offset offset: this.constants.offset

8
src/widget/multitree/trigger/searcher.multi.tree.js

@ -10,6 +10,9 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), { return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-multi-tree-searcher", baseCls: "bi-multi-tree-searcher",
itemsCreator: BI.emptyFn, itemsCreator: BI.emptyFn,
valueFormatter: function (v) {
return v;
},
popup: {}, popup: {},
adapter: null, adapter: null,
@ -105,6 +108,7 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
}, },
setState: function (ob) { setState: function (ob) {
var o = this.options;
ob || (ob = {}); ob || (ob = {});
ob.value || (ob.value = {}); ob.value || (ob.value = {});
if (BI.isNumber(ob)) { if (BI.isNumber(ob)) {
@ -115,7 +119,7 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
var text = ""; var text = "";
BI.each(ob.value, function (name, children) { BI.each(ob.value, function (name, children) {
var childNodes = getChildrenNode(children); var childNodes = getChildrenNode(children);
text += name + (childNodes === "" ? "" : (":" + childNodes)) + "; "; text += (o.valueFormatter(name + "") || name) + (childNodes === "" ? "" : (":" + childNodes)) + "; ";
}); });
this.editor.setState(text); this.editor.setState(text);
} }
@ -126,7 +130,7 @@ BI.MultiTreeSearcher = BI.inherit(BI.Widget, {
BI.each(ob, function (name, children) { BI.each(ob, function (name, children) {
index++; index++;
var childNodes = getChildrenNode(children); var childNodes = getChildrenNode(children);
text += name + (childNodes === "" ? "" : (":" + childNodes)) + (index === size ? "" : ","); text += (o.valueFormatter(name + "") || name) + (childNodes === "" ? "" : (":" + childNodes)) + (index === size ? "" : ",");
}); });
return text; return text;
} }

Loading…
Cancel
Save