Browse Source

Merging in latest from upstream (~GUY/fineui:refs/heads/master)

* commit '1007647d229d8efea7d05159576a73de246c6c7e':
  update
  add
  add
  add
  bug
es6
Young 8 years ago
parent
commit
af6bc84dca
  1. 18
      bi/base.js
  2. 18
      bi/case.js
  3. 59
      bi/core.js
  4. 96
      bi/widget.js
  5. 5
      demo/config.js
  6. 21
      demo/js/component/demo.treevaluechoosercombo.js
  7. 26
      demo/js/component/demo.treevaluechooserpane.js
  8. 6
      demo/js/component/demo.valuechooserpane.js
  9. 18
      docs/base.js
  10. 18
      docs/case.js
  11. 59
      docs/core.js
  12. 58
      docs/demo.js
  13. 96
      docs/widget.js
  14. 2
      src/base/tree/asynctree.js
  15. 2
      src/base/tree/parttree.js
  16. 14
      src/base/tree/treeview.js
  17. 18
      src/case/toolbar/toolbar.multiselect.js
  18. 75
      src/component/treevaluechooser/abstract.treevaluechooser.js
  19. 2
      src/component/valuechooser/pane.valuechooser.js
  20. 8
      src/core/base.js
  21. 51
      src/core/utils/tree.js
  22. 6
      src/widget/multiselectlist/multiselectlist.js

18
bi/base.js

@ -1710,7 +1710,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
_getNodeValue: function (node) {
//去除标红
return node.value || node.text.replace(/<[^>]+>/g, "");
return node.value == null ? node.text.replace(/<[^>]+>/g, "") : node.value;
},
//获取半选框值
@ -1802,6 +1802,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
var self = this, o = this.options;
var ns = BI.Tree.arrayFormat(nodes);
BI.each(ns, function (i, n) {
n.title = n.title || n.text || n.value;
//处理标红
if (BI.isKey(o.paras.keyword)) {
n.text = $("<div>").__textKeywordMarked__(n.text, o.paras.keyword, n.py).html();
@ -1944,7 +1945,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
},
setSelectedValue: function (value) {
this.options.paras.selectedValues = value || {};
this.options.paras.selectedValues = BI.deepClone(value) || {};
this.selectedValues = BI.deepClone(value) || {};
},
@ -1963,7 +1964,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
});
},
getExpandedValue: function(){
getExpandedValue: function () {
if (!this.nodes) {
return null;
}
@ -1980,14 +1981,9 @@ BI.TreeView = BI.inherit(BI.Pane, {
return this._getSelectedValues();
},
empty: function () {
BI.isNotNull(this.nodes) && this.nodes.destroy();
},
destroy: function () {
destroyed: function () {
this.stop();
this.nodes && this.nodes.destroy();
BI.TreeView.superclass.destroy.apply(this, arguments);
}
});
BI.extend(BI.TreeView, {
@ -2190,7 +2186,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}
var checkedValues = this._getSelectedValues();
if (BI.isEmpty(checkedValues)) {
return this.selectedValues;
return BI.deepClone(this.selectedValues);
}
if (BI.isEmpty(this.selectedValues)) {
return checkedValues;
@ -2257,7 +2253,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
} else {
o.itemsCreator(BI.extend({}, o.paras, {
type: BI.TreeView.REQ_TYPE_CALCULATE_SELECT_DATA,
type: BI.TreeView.REQ_TYPE_SELECT_DATA,
selectedValues: this.selectedValues,
notSelectedValue: name,
parentValues: parentValues

18
bi/case.js

@ -10269,7 +10269,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
height: 25,
text: BI.i18nText('BI-Select_All'),
isAllCheckedBySelectedValue: BI.emptyFn,
onCheck: BI.emptyFn,
isHalfCheckedBySelectedValue: function (selectedValues) {
return selectedValues.length > 0;
}
@ -10283,7 +10282,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
stopPropagation: true,
handler: function () {
self.setSelected(self.isSelected());
o.onCheck.call(self, self.isSelected());
}
});
this.half = BI.createWidget({
@ -10291,7 +10289,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
stopPropagation: true,
handler: function () {
self.setSelected(true);
o.onCheck.call(self, self.isSelected());
}
});
this.checkbox.on(BI.Controller.EVENT_CHANGE, function () {
@ -10334,21 +10331,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
this.half.invisible();
},
doClick: function () {
var isHalf = this.isHalfSelected(), isSelected = this.isSelected();
if (isHalf === true) {
this.setSelected(true);
} else {
this.setSelected(!isSelected);
}
if (this.isValid()) {
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, this.getValue(), this);
this.options.onCheck.call(this, this.isSelected());
this.fireEvent(BI.MultiSelectBar.EVENT_CHANGE, this.isSelected(), this);
}
},
setSelected: function (v) {
this.checkbox.setSelected(v);
this.setHalfSelected(false);

59
bi/core.js

@ -2352,15 +2352,15 @@ if (!window.BI) {
},
has: function (obj, keys) {
if (BI.isKey(keys)) {
return _.has.apply(_, arguments);
}
if (!keys || BI.isEmpty(keys)) {
if (BI.isArray(keys)) {
if (keys.length === 0) {
return false;
}
return BI.every(keys, function (i, key) {
return _.has(obj, key);
});
}
return _.has.apply(_, arguments);
},
//数字和字符串可以作为key
@ -9990,7 +9990,7 @@ $.extend(BI, {
},
isRoot: function (node) {
return node === this.root || node.id === this.root.id;
return node === this.root;
},
getRoot: function () {
@ -10367,7 +10367,7 @@ $.extend(BI, {
if (BI.isArray(nodes)) {
for (var i = 0, l = nodes.length; i < l; i++) {
var node = BI.clone(nodes[i]);
node.pId = pId;
node.pId = node.pId == null ? pId : node.pId;
delete node.children;
r.push(node);
if (nodes[i]["children"]) {
@ -10376,7 +10376,7 @@ $.extend(BI, {
}
} else {
var newNodes = BI.clone(nodes);
newNodes.pId = pId;
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId;
delete newNodes.children;
r.push(newNodes);
if (nodes["children"]) {
@ -10387,21 +10387,25 @@ $.extend(BI, {
},
arrayFormat: function (nodes, pId) {
if (!nodes) return [];
if (!nodes) {
return [];
}
var r = [];
if (BI.isArray(nodes)) {
for (var i = 0, l = nodes.length; i < l; i++) {
var node = nodes[i];
node.pId = node.pId == null ? pId : node.pId;
r.push(node);
if (nodes[i]["children"]) {
r = r.concat(BI.Tree.transformToArrayFormat(nodes[i]["children"], node.id));
r = r.concat(BI.Tree.arrayFormat(nodes[i]["children"], node.id));
}
}
} else {
var newNodes = nodes;
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId;
r.push(newNodes);
if (nodes["children"]) {
r = r.concat(BI.Tree.transformToArrayFormat(nodes["children"], newNodes.id));
r = r.concat(BI.Tree.arrayFormat(nodes["children"], newNodes.id));
}
}
return r;
@ -10417,13 +10421,13 @@ $.extend(BI, {
var r = [];
var tmpMap = [];
for (i = 0, l = sNodes.length; i < l; i++) {
if(BI.isNull(sNodes[i].id)) {
if (BI.isNull(sNodes[i].id)) {
return sNodes;
}
tmpMap[sNodes[i].id] = BI.clone(sNodes[i]);
}
for (i = 0, l = sNodes.length; i < l; i++) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id != sNodes[i].pId) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) {
if (!tmpMap[sNodes[i].pId].children) {
tmpMap[sNodes[i].pId].children = [];
}
@ -10439,6 +10443,37 @@ $.extend(BI, {
}
},
treeFormat: function (sNodes) {
var i, l;
if (!sNodes) {
return [];
}
if (BI.isArray(sNodes)) {
var r = [];
var tmpMap = [];
for (i = 0, l = sNodes.length; i < l; i++) {
if (BI.isNull(sNodes[i].id)) {
return sNodes;
}
tmpMap[sNodes[i].id] = sNodes[i];
}
for (i = 0, l = sNodes.length; i < l; i++) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) {
if (!tmpMap[sNodes[i].pId].children) {
tmpMap[sNodes[i].pId].children = [];
}
tmpMap[sNodes[i].pId].children.push(tmpMap[sNodes[i].id]);
} else {
r.push(tmpMap[sNodes[i].id]);
}
}
return r;
} else {
return [sNodes];
}
},
traversal: function (array, callback) {
if (BI.isNull(array)) {
return;

96
bi/widget.js

@ -10973,6 +10973,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.setValue(self.storeValue);
};
this.adapter = BI.createWidget({
@ -11032,6 +11033,8 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
self._showAdapter();
self._setStartValue("");
self.adapter.setValue(self.storeValue);
//需要刷新回到初始界面,否则搜索的结果不能放在最前面
self.adapter.populate();
}
}, {
eventName: BI.Searcher.EVENT_PAUSE,
@ -11043,7 +11046,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
value: [keyword]
}, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
@ -11063,13 +11065,11 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
self.adapter.populate();
self._setStartValue("");
} else {
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
}
@ -11433,6 +11433,14 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
});
},
stopSearch: function () {
this.trigger.stopSearch();
},
updateValue: function (v) {
this.adapter.updateValue(v);
},
getValue: function () {
return this.storeValue.value;
},
@ -11482,6 +11490,11 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
this.popup.setValue(v.value);
},
updateValue: function (v) {
this.popup.updateValue(v);
this.popup.refresh();
},
populate: function (config) {
this.popup.stroke(config);
}
@ -17173,27 +17186,9 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
_initData: function (items) {
this.items = items;
var nodes = BI.Tree.transformToTreeFormat(items);
var nodes = BI.Tree.treeFormat(items);
this.tree = new BI.Tree();
this.tree.initTree(nodes);
this._initMap();
this._initFloors();
},
_initMap: function () {
var map = this.map = {};
BI.each(this.items, function (i, item) {
map[item.value] = item;
});
},
_initFloors: function () {
this.floors = -1;
var root = this.tree.getRoot();
while (root) {
this.floors++;
root = root.getChildren()[0];
}
},
_itemsCreator: function (options, callback) {
@ -17237,32 +17232,29 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
return;
}
doCheck(0, [], this.tree.getRoot(), selectedValues);
doCheck([], this.tree.getRoot(), selectedValues);
callback({
items: result
});
function doCheck(floor, parentValues, node, selected) {
if (floor >= self.floors) {
return;
}
function doCheck(parentValues, node, selected) {
if (selected == null || BI.isEmpty(selected)) {
BI.each(node.getChildren(), function (i, child) {
var newParents = BI.clone(parentValues);
newParents.push(child.value);
var llen = self._getChildCount(newParents);
createOneJson(child, node.id, llen);
doCheck(floor + 1, newParents, child, {});
doCheck(newParents, child, {});
});
return;
}
BI.each(selected, function (k) {
var node = self._getNode(k);
var node = self._getNode(parentValues, k);
var newParents = BI.clone(parentValues);
newParents.push(node.value);
createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents));
doCheck(floor + 1, newParents, node, selected[k]);
doCheck(newParents, node, selected[k]);
})
}
@ -17352,9 +17344,6 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
if (self._isMatch(current, keyword)) {
return true;
}
if (deep >= self.floors) {
return false;
}
var children = self._getChildren(newParents);
@ -17490,9 +17479,6 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
return [true, checked];
}
if (deep >= self.floors) {
return [false, false];
}
var newParents = BI.clone(parentValues);
newParents.push(current);
var children = self._getChildren(newParents);
@ -17517,14 +17503,14 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
}
function createOneJson(parentValues, value, isOpen, checked, half, flag, result) {
var node = self.map[value];
var node = self._getNode(parentValues, value)
result.push({
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
title: node.title,
isParent: parentValues.length + 1 < self.floors,
isParent: node.getChildrenLength() > 0,
open: isOpen,
checked: checked,
halfCheck: half,
@ -17608,7 +17594,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
value: nodes[i].value,
text: nodes[i].text,
times: 1,
isParent: parentValues.length + 1 < this.floors,
isParent: nodes[i].getChildrenLength() > 0,
checked: state[0],
halfCheck: state[1]
})
@ -17655,14 +17641,14 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
function getCheckState(current, parentValues, valueMap, checkState) {
var checked = checkState.checked, half = checkState.half;
var hasChild = parentValues.length + 1 < self.floors;
var tempCheck = false, halfCheck = false;
if (BI.has(valueMap, current)) {
//可能是半选
if (valueMap[current][0] === 1) {
var values = BI.clone(parentValues);
values.push(current);
if (hasChild && self._getChildCount(values) !== valueMap[current][1]) {
var childCount = self._getChildCount(values);
if (childCount > 0 && childCount !== valueMap[current][1]) {
halfCheck = true;
}
} else if (valueMap[current][0] === 2) {
@ -17695,14 +17681,34 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
return finded.finded.length > 0 || finded.matched.length > 0;
},
_getNode: function (v) {
return this.tree.search(v, "value");
_getNode: function (parentValues, v) {
var self = this;
var findedParentNode;
var index = 0;
this.tree.traverse(function (node) {
if (self.tree.isRoot(node)) {
return;
}
if (index > parentValues.length) {
return false;
}
if (index === parentValues.length && node.value === v) {
findedParentNode = node;
return false;
}
if (node.value === parentValues[index]) {
index++;
return;
}
return true;
});
return findedParentNode;
},
_getChildren: function (parentValues) {
if (parentValues.length > 0) {
var value = BI.last(parentValues);
var parent = this.tree.search(value, "value");
var parent = this._getNode(parentValues.slice(0, parentValues.length - 1), value);
} else {
var parent = this.tree.getRoot();
}
@ -17970,8 +17976,6 @@ BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-pane",
width: 200,
height: 30,
items: null,
itemsCreator: BI.emptyFn,
cache: true

5
demo/config.js

File diff suppressed because one or more lines are too long

21
demo/js/component/demo.treevaluechoosercombo.js

@ -4,29 +4,12 @@ Demo.TreeValueChooser = BI.inherit(BI.Widget, {
},
render: function () {
var tree = [];
for (var i = 0; i < 221; i++) {
tree.push({
value: "" + i + "",
text: "" + i + "",
id: i + "",
pId: null
});
for (var j = 0; j < 9; j++) {
tree.push({
value: i + "-" + j,
text: j + "",
id: i + "-" + j,
pId: i + ""
})
}
}
var widget = BI.createWidget({
type: "bi.tree_value_chooser_combo",
width: 300,
items: tree,
// items: BI.deepClone(Demo.CONSTANTS.TREEITEMS),
itemsCreator: function (op, callback) {
callback(tree);
callback(BI.deepClone(Demo.CONSTANTS.TREEITEMS));
}
});
return {

26
demo/js/component/demo.treevaluechooserpane.js

@ -4,30 +4,12 @@ Demo.TreeValueChooser = BI.inherit(BI.Widget, {
},
render: function () {
var tree = [];
for (var i = 0; i < 221; i++) {
tree.push({
value: "" + i + "",
text: "" + i + "",
id: i + "",
pId: null
});
for (var j = 0; j < 9; j++) {
tree.push({
value: i + "-" + j,
text: j + "",
id: i + "-" + j,
pId: i + ""
})
}
}
return {
type: "bi.tree_value_chooser_pane",
width: 300,
items: tree,
itemsCreator: function (op, callback) {
callback(tree);
}
items: BI.deepClone(Demo.CONSTANTS.TREEITEMS),
// itemsCreator: function (op, callback) {
// callback(tree);
// }
};
}
});

6
demo/js/component/demo.valuechooserpane.js

@ -6,9 +6,9 @@ Demo.ValueChooserPane = BI.inherit(BI.Widget, {
return {
type: "bi.value_chooser_pane",
items: BI.deepClone(Demo.CONSTANTS.ITEMS),
itemsCreator: function (op, callback) {
callback(BI.deepClone(Demo.CONSTANTS.ITEMS));
}
// itemsCreator: function (op, callback) {
// callback(BI.deepClone(Demo.CONSTANTS.ITEMS));
// }
};
}
});

18
docs/base.js

@ -1710,7 +1710,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
_getNodeValue: function (node) {
//去除标红
return node.value || node.text.replace(/<[^>]+>/g, "");
return node.value == null ? node.text.replace(/<[^>]+>/g, "") : node.value;
},
//获取半选框值
@ -1802,6 +1802,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
var self = this, o = this.options;
var ns = BI.Tree.arrayFormat(nodes);
BI.each(ns, function (i, n) {
n.title = n.title || n.text || n.value;
//处理标红
if (BI.isKey(o.paras.keyword)) {
n.text = $("<div>").__textKeywordMarked__(n.text, o.paras.keyword, n.py).html();
@ -1944,7 +1945,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
},
setSelectedValue: function (value) {
this.options.paras.selectedValues = value || {};
this.options.paras.selectedValues = BI.deepClone(value) || {};
this.selectedValues = BI.deepClone(value) || {};
},
@ -1963,7 +1964,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
});
},
getExpandedValue: function(){
getExpandedValue: function () {
if (!this.nodes) {
return null;
}
@ -1980,14 +1981,9 @@ BI.TreeView = BI.inherit(BI.Pane, {
return this._getSelectedValues();
},
empty: function () {
BI.isNotNull(this.nodes) && this.nodes.destroy();
},
destroy: function () {
destroyed: function () {
this.stop();
this.nodes && this.nodes.destroy();
BI.TreeView.superclass.destroy.apply(this, arguments);
}
});
BI.extend(BI.TreeView, {
@ -2190,7 +2186,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}
var checkedValues = this._getSelectedValues();
if (BI.isEmpty(checkedValues)) {
return this.selectedValues;
return BI.deepClone(this.selectedValues);
}
if (BI.isEmpty(this.selectedValues)) {
return checkedValues;
@ -2257,7 +2253,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
} else {
o.itemsCreator(BI.extend({}, o.paras, {
type: BI.TreeView.REQ_TYPE_CALCULATE_SELECT_DATA,
type: BI.TreeView.REQ_TYPE_SELECT_DATA,
selectedValues: this.selectedValues,
notSelectedValue: name,
parentValues: parentValues

18
docs/case.js

@ -10269,7 +10269,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
height: 25,
text: BI.i18nText('BI-Select_All'),
isAllCheckedBySelectedValue: BI.emptyFn,
onCheck: BI.emptyFn,
isHalfCheckedBySelectedValue: function (selectedValues) {
return selectedValues.length > 0;
}
@ -10283,7 +10282,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
stopPropagation: true,
handler: function () {
self.setSelected(self.isSelected());
o.onCheck.call(self, self.isSelected());
}
});
this.half = BI.createWidget({
@ -10291,7 +10289,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
stopPropagation: true,
handler: function () {
self.setSelected(true);
o.onCheck.call(self, self.isSelected());
}
});
this.checkbox.on(BI.Controller.EVENT_CHANGE, function () {
@ -10334,21 +10331,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
this.half.invisible();
},
doClick: function () {
var isHalf = this.isHalfSelected(), isSelected = this.isSelected();
if (isHalf === true) {
this.setSelected(true);
} else {
this.setSelected(!isSelected);
}
if (this.isValid()) {
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, this.getValue(), this);
this.options.onCheck.call(this, this.isSelected());
this.fireEvent(BI.MultiSelectBar.EVENT_CHANGE, this.isSelected(), this);
}
},
setSelected: function (v) {
this.checkbox.setSelected(v);
this.setHalfSelected(false);

59
docs/core.js

@ -13494,15 +13494,15 @@ if (!window.BI) {
},
has: function (obj, keys) {
if (BI.isKey(keys)) {
return _.has.apply(_, arguments);
}
if (!keys || BI.isEmpty(keys)) {
if (BI.isArray(keys)) {
if (keys.length === 0) {
return false;
}
return BI.every(keys, function (i, key) {
return _.has(obj, key);
});
}
return _.has.apply(_, arguments);
},
//数字和字符串可以作为key
@ -18448,7 +18448,7 @@ $.extend(BI, {
},
isRoot: function (node) {
return node === this.root || node.id === this.root.id;
return node === this.root;
},
getRoot: function () {
@ -18825,7 +18825,7 @@ $.extend(BI, {
if (BI.isArray(nodes)) {
for (var i = 0, l = nodes.length; i < l; i++) {
var node = BI.clone(nodes[i]);
node.pId = pId;
node.pId = node.pId == null ? pId : node.pId;
delete node.children;
r.push(node);
if (nodes[i]["children"]) {
@ -18834,7 +18834,7 @@ $.extend(BI, {
}
} else {
var newNodes = BI.clone(nodes);
newNodes.pId = pId;
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId;
delete newNodes.children;
r.push(newNodes);
if (nodes["children"]) {
@ -18845,21 +18845,25 @@ $.extend(BI, {
},
arrayFormat: function (nodes, pId) {
if (!nodes) return [];
if (!nodes) {
return [];
}
var r = [];
if (BI.isArray(nodes)) {
for (var i = 0, l = nodes.length; i < l; i++) {
var node = nodes[i];
node.pId = node.pId == null ? pId : node.pId;
r.push(node);
if (nodes[i]["children"]) {
r = r.concat(BI.Tree.transformToArrayFormat(nodes[i]["children"], node.id));
r = r.concat(BI.Tree.arrayFormat(nodes[i]["children"], node.id));
}
}
} else {
var newNodes = nodes;
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId;
r.push(newNodes);
if (nodes["children"]) {
r = r.concat(BI.Tree.transformToArrayFormat(nodes["children"], newNodes.id));
r = r.concat(BI.Tree.arrayFormat(nodes["children"], newNodes.id));
}
}
return r;
@ -18875,13 +18879,13 @@ $.extend(BI, {
var r = [];
var tmpMap = [];
for (i = 0, l = sNodes.length; i < l; i++) {
if(BI.isNull(sNodes[i].id)) {
if (BI.isNull(sNodes[i].id)) {
return sNodes;
}
tmpMap[sNodes[i].id] = BI.clone(sNodes[i]);
}
for (i = 0, l = sNodes.length; i < l; i++) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id != sNodes[i].pId) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) {
if (!tmpMap[sNodes[i].pId].children) {
tmpMap[sNodes[i].pId].children = [];
}
@ -18897,6 +18901,37 @@ $.extend(BI, {
}
},
treeFormat: function (sNodes) {
var i, l;
if (!sNodes) {
return [];
}
if (BI.isArray(sNodes)) {
var r = [];
var tmpMap = [];
for (i = 0, l = sNodes.length; i < l; i++) {
if (BI.isNull(sNodes[i].id)) {
return sNodes;
}
tmpMap[sNodes[i].id] = sNodes[i];
}
for (i = 0, l = sNodes.length; i < l; i++) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) {
if (!tmpMap[sNodes[i].pId].children) {
tmpMap[sNodes[i].pId].children = [];
}
tmpMap[sNodes[i].pId].children.push(tmpMap[sNodes[i].id]);
} else {
r.push(tmpMap[sNodes[i].id]);
}
}
return r;
} else {
return [sNodes];
}
},
traversal: function (array, callback) {
if (BI.isNull(array)) {
return;

58
docs/demo.js

File diff suppressed because one or more lines are too long

96
docs/widget.js

@ -10973,6 +10973,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.setValue(self.storeValue);
};
this.adapter = BI.createWidget({
@ -11032,6 +11033,8 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
self._showAdapter();
self._setStartValue("");
self.adapter.setValue(self.storeValue);
//需要刷新回到初始界面,否则搜索的结果不能放在最前面
self.adapter.populate();
}
}, {
eventName: BI.Searcher.EVENT_PAUSE,
@ -11043,7 +11046,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
value: [keyword]
}, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
@ -11063,13 +11065,11 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
self.adapter.populate();
self._setStartValue("");
} else {
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
}
@ -11433,6 +11433,14 @@ BI.MultiSelectTree = BI.inherit(BI.Widget, {
});
},
stopSearch: function () {
this.trigger.stopSearch();
},
updateValue: function (v) {
this.adapter.updateValue(v);
},
getValue: function () {
return this.storeValue.value;
},
@ -11482,6 +11490,11 @@ BI.MultiSelectTreePopup = BI.inherit(BI.Widget, {
this.popup.setValue(v.value);
},
updateValue: function (v) {
this.popup.updateValue(v);
this.popup.refresh();
},
populate: function (config) {
this.popup.stroke(config);
}
@ -17173,27 +17186,9 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
_initData: function (items) {
this.items = items;
var nodes = BI.Tree.transformToTreeFormat(items);
var nodes = BI.Tree.treeFormat(items);
this.tree = new BI.Tree();
this.tree.initTree(nodes);
this._initMap();
this._initFloors();
},
_initMap: function () {
var map = this.map = {};
BI.each(this.items, function (i, item) {
map[item.value] = item;
});
},
_initFloors: function () {
this.floors = -1;
var root = this.tree.getRoot();
while (root) {
this.floors++;
root = root.getChildren()[0];
}
},
_itemsCreator: function (options, callback) {
@ -17237,32 +17232,29 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
return;
}
doCheck(0, [], this.tree.getRoot(), selectedValues);
doCheck([], this.tree.getRoot(), selectedValues);
callback({
items: result
});
function doCheck(floor, parentValues, node, selected) {
if (floor >= self.floors) {
return;
}
function doCheck(parentValues, node, selected) {
if (selected == null || BI.isEmpty(selected)) {
BI.each(node.getChildren(), function (i, child) {
var newParents = BI.clone(parentValues);
newParents.push(child.value);
var llen = self._getChildCount(newParents);
createOneJson(child, node.id, llen);
doCheck(floor + 1, newParents, child, {});
doCheck(newParents, child, {});
});
return;
}
BI.each(selected, function (k) {
var node = self._getNode(k);
var node = self._getNode(parentValues, k);
var newParents = BI.clone(parentValues);
newParents.push(node.value);
createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents));
doCheck(floor + 1, newParents, node, selected[k]);
doCheck(newParents, node, selected[k]);
})
}
@ -17352,9 +17344,6 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
if (self._isMatch(current, keyword)) {
return true;
}
if (deep >= self.floors) {
return false;
}
var children = self._getChildren(newParents);
@ -17490,9 +17479,6 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
return [true, checked];
}
if (deep >= self.floors) {
return [false, false];
}
var newParents = BI.clone(parentValues);
newParents.push(current);
var children = self._getChildren(newParents);
@ -17517,14 +17503,14 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
}
function createOneJson(parentValues, value, isOpen, checked, half, flag, result) {
var node = self.map[value];
var node = self._getNode(parentValues, value)
result.push({
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
title: node.title,
isParent: parentValues.length + 1 < self.floors,
isParent: node.getChildrenLength() > 0,
open: isOpen,
checked: checked,
halfCheck: half,
@ -17608,7 +17594,7 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
value: nodes[i].value,
text: nodes[i].text,
times: 1,
isParent: parentValues.length + 1 < this.floors,
isParent: nodes[i].getChildrenLength() > 0,
checked: state[0],
halfCheck: state[1]
})
@ -17655,14 +17641,14 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
function getCheckState(current, parentValues, valueMap, checkState) {
var checked = checkState.checked, half = checkState.half;
var hasChild = parentValues.length + 1 < self.floors;
var tempCheck = false, halfCheck = false;
if (BI.has(valueMap, current)) {
//可能是半选
if (valueMap[current][0] === 1) {
var values = BI.clone(parentValues);
values.push(current);
if (hasChild && self._getChildCount(values) !== valueMap[current][1]) {
var childCount = self._getChildCount(values);
if (childCount > 0 && childCount !== valueMap[current][1]) {
halfCheck = true;
}
} else if (valueMap[current][0] === 2) {
@ -17695,14 +17681,34 @@ BI.shortcut('bi.all_value_chooser_pane', BI.AllValueChooserPane);BI.AbstractTree
return finded.finded.length > 0 || finded.matched.length > 0;
},
_getNode: function (v) {
return this.tree.search(v, "value");
_getNode: function (parentValues, v) {
var self = this;
var findedParentNode;
var index = 0;
this.tree.traverse(function (node) {
if (self.tree.isRoot(node)) {
return;
}
if (index > parentValues.length) {
return false;
}
if (index === parentValues.length && node.value === v) {
findedParentNode = node;
return false;
}
if (node.value === parentValues[index]) {
index++;
return;
}
return true;
});
return findedParentNode;
},
_getChildren: function (parentValues) {
if (parentValues.length > 0) {
var value = BI.last(parentValues);
var parent = this.tree.search(value, "value");
var parent = this._getNode(parentValues.slice(0, parentValues.length - 1), value);
} else {
var parent = this.tree.getRoot();
}
@ -17970,8 +17976,6 @@ BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-pane",
width: 200,
height: 30,
items: null,
itemsCreator: BI.emptyFn,
cache: true

2
src/base/tree/asynctree.js

@ -187,7 +187,7 @@ BI.AsyncTree = BI.inherit(BI.TreeView, {
}
var checkedValues = this._getSelectedValues();
if (BI.isEmpty(checkedValues)) {
return this.selectedValues;
return BI.deepClone(this.selectedValues);
}
if (BI.isEmpty(this.selectedValues)) {
return checkedValues;

2
src/base/tree/parttree.js

@ -46,7 +46,7 @@ BI.PartTree = BI.inherit(BI.AsyncTree, {
BI.AsyncTree.superclass._selectTreeNode.apply(self, arguments);
} else {
o.itemsCreator(BI.extend({}, o.paras, {
type: BI.TreeView.REQ_TYPE_CALCULATE_SELECT_DATA,
type: BI.TreeView.REQ_TYPE_SELECT_DATA,
selectedValues: this.selectedValues,
notSelectedValue: name,
parentValues: parentValues

14
src/base/tree/treeview.js

@ -216,7 +216,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
_getNodeValue: function (node) {
//去除标红
return node.value || node.text.replace(/<[^>]+>/g, "");
return node.value == null ? node.text.replace(/<[^>]+>/g, "") : node.value;
},
//获取半选框值
@ -308,6 +308,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
var self = this, o = this.options;
var ns = BI.Tree.arrayFormat(nodes);
BI.each(ns, function (i, n) {
n.title = n.title || n.text || n.value;
//处理标红
if (BI.isKey(o.paras.keyword)) {
n.text = $("<div>").__textKeywordMarked__(n.text, o.paras.keyword, n.py).html();
@ -450,7 +451,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
},
setSelectedValue: function (value) {
this.options.paras.selectedValues = value || {};
this.options.paras.selectedValues = BI.deepClone(value) || {};
this.selectedValues = BI.deepClone(value) || {};
},
@ -469,7 +470,7 @@ BI.TreeView = BI.inherit(BI.Pane, {
});
},
getExpandedValue: function(){
getExpandedValue: function () {
if (!this.nodes) {
return null;
}
@ -486,14 +487,9 @@ BI.TreeView = BI.inherit(BI.Pane, {
return this._getSelectedValues();
},
empty: function () {
BI.isNotNull(this.nodes) && this.nodes.destroy();
},
destroy: function () {
destroyed: function () {
this.stop();
this.nodes && this.nodes.destroy();
BI.TreeView.superclass.destroy.apply(this, arguments);
}
});
BI.extend(BI.TreeView, {

18
src/case/toolbar/toolbar.multiselect.js

@ -12,7 +12,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
height: 25,
text: BI.i18nText('BI-Select_All'),
isAllCheckedBySelectedValue: BI.emptyFn,
onCheck: BI.emptyFn,
isHalfCheckedBySelectedValue: function (selectedValues) {
return selectedValues.length > 0;
}
@ -26,7 +25,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
stopPropagation: true,
handler: function () {
self.setSelected(self.isSelected());
o.onCheck.call(self, self.isSelected());
}
});
this.half = BI.createWidget({
@ -34,7 +32,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
stopPropagation: true,
handler: function () {
self.setSelected(true);
o.onCheck.call(self, self.isSelected());
}
});
this.checkbox.on(BI.Controller.EVENT_CHANGE, function () {
@ -77,21 +74,6 @@ BI.MultiSelectBar = BI.inherit(BI.BasicButton, {
this.half.invisible();
},
doClick: function () {
var isHalf = this.isHalfSelected(), isSelected = this.isSelected();
if (isHalf === true) {
this.setSelected(true);
} else {
this.setSelected(!isSelected);
}
if (this.isValid()) {
this.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CLICK, this.getValue(), this);
this.options.onCheck.call(this, this.isSelected());
this.fireEvent(BI.MultiSelectBar.EVENT_CHANGE, this.isSelected(), this);
}
},
setSelected: function (v) {
this.checkbox.setSelected(v);
this.setHalfSelected(false);

75
src/component/treevaluechooser/abstract.treevaluechooser.js

@ -13,27 +13,9 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
_initData: function (items) {
this.items = items;
var nodes = BI.Tree.transformToTreeFormat(items);
var nodes = BI.Tree.treeFormat(items);
this.tree = new BI.Tree();
this.tree.initTree(nodes);
this._initMap();
this._initFloors();
},
_initMap: function () {
var map = this.map = {};
BI.each(this.items, function (i, item) {
map[item.value] = item;
});
},
_initFloors: function () {
this.floors = -1;
var root = this.tree.getRoot();
while (root) {
this.floors++;
root = root.getChildren()[0];
}
},
_itemsCreator: function (options, callback) {
@ -77,32 +59,29 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
return;
}
doCheck(0, [], this.tree.getRoot(), selectedValues);
doCheck([], this.tree.getRoot(), selectedValues);
callback({
items: result
});
function doCheck(floor, parentValues, node, selected) {
if (floor >= self.floors) {
return;
}
function doCheck(parentValues, node, selected) {
if (selected == null || BI.isEmpty(selected)) {
BI.each(node.getChildren(), function (i, child) {
var newParents = BI.clone(parentValues);
newParents.push(child.value);
var llen = self._getChildCount(newParents);
createOneJson(child, node.id, llen);
doCheck(floor + 1, newParents, child, {});
doCheck(newParents, child, {});
});
return;
}
BI.each(selected, function (k) {
var node = self._getNode(k);
var node = self._getNode(parentValues, k);
var newParents = BI.clone(parentValues);
newParents.push(node.value);
createOneJson(node, BI.last(parentValues), getCount(selected[k], newParents));
doCheck(floor + 1, newParents, node, selected[k]);
doCheck(newParents, node, selected[k]);
})
}
@ -192,9 +171,6 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
if (self._isMatch(current, keyword)) {
return true;
}
if (deep >= self.floors) {
return false;
}
var children = self._getChildren(newParents);
@ -330,9 +306,6 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result);
return [true, checked];
}
if (deep >= self.floors) {
return [false, false];
}
var newParents = BI.clone(parentValues);
newParents.push(current);
var children = self._getChildren(newParents);
@ -357,14 +330,14 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
}
function createOneJson(parentValues, value, isOpen, checked, half, flag, result) {
var node = self.map[value];
var node = self._getNode(parentValues, value)
result.push({
id: node.id,
pId: node.pId,
text: node.text,
value: node.value,
title: node.title,
isParent: parentValues.length + 1 < self.floors,
isParent: node.getChildrenLength() > 0,
open: isOpen,
checked: checked,
halfCheck: half,
@ -448,7 +421,7 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
value: nodes[i].value,
text: nodes[i].text,
times: 1,
isParent: parentValues.length + 1 < this.floors,
isParent: nodes[i].getChildrenLength() > 0,
checked: state[0],
halfCheck: state[1]
})
@ -495,14 +468,14 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
function getCheckState(current, parentValues, valueMap, checkState) {
var checked = checkState.checked, half = checkState.half;
var hasChild = parentValues.length + 1 < self.floors;
var tempCheck = false, halfCheck = false;
if (BI.has(valueMap, current)) {
//可能是半选
if (valueMap[current][0] === 1) {
var values = BI.clone(parentValues);
values.push(current);
if (hasChild && self._getChildCount(values) !== valueMap[current][1]) {
var childCount = self._getChildCount(values);
if (childCount > 0 && childCount !== valueMap[current][1]) {
halfCheck = true;
}
} else if (valueMap[current][0] === 2) {
@ -535,14 +508,34 @@ BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, {
return finded.finded.length > 0 || finded.matched.length > 0;
},
_getNode: function (v) {
return this.tree.search(v, "value");
_getNode: function (parentValues, v) {
var self = this;
var findedParentNode;
var index = 0;
this.tree.traverse(function (node) {
if (self.tree.isRoot(node)) {
return;
}
if (index > parentValues.length) {
return false;
}
if (index === parentValues.length && node.value === v) {
findedParentNode = node;
return false;
}
if (node.value === parentValues[index]) {
index++;
return;
}
return true;
});
return findedParentNode;
},
_getChildren: function (parentValues) {
if (parentValues.length > 0) {
var value = BI.last(parentValues);
var parent = this.tree.search(value, "value");
var parent = this._getNode(parentValues.slice(0, parentValues.length - 1), value);
} else {
var parent = this.tree.getRoot();
}

2
src/component/valuechooser/pane.valuechooser.js

@ -11,8 +11,6 @@ BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, {
_defaultConfig: function () {
return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), {
baseCls: "bi-value-chooser-pane",
width: 200,
height: 30,
items: null,
itemsCreator: BI.emptyFn,
cache: true

8
src/core/base.js

@ -457,15 +457,15 @@ if (!window.BI) {
},
has: function (obj, keys) {
if (BI.isKey(keys)) {
return _.has.apply(_, arguments);
}
if (!keys || BI.isEmpty(keys)) {
if (BI.isArray(keys)) {
if (keys.length === 0) {
return false;
}
return BI.every(keys, function (i, key) {
return _.has(obj, key);
});
}
return _.has.apply(_, arguments);
},
//数字和字符串可以作为key

51
src/core/utils/tree.js

@ -17,7 +17,7 @@
},
isRoot: function (node) {
return node === this.root || node.id === this.root.id;
return node === this.root;
},
getRoot: function () {
@ -394,7 +394,7 @@
if (BI.isArray(nodes)) {
for (var i = 0, l = nodes.length; i < l; i++) {
var node = BI.clone(nodes[i]);
node.pId = pId;
node.pId = node.pId == null ? pId : node.pId;
delete node.children;
r.push(node);
if (nodes[i]["children"]) {
@ -403,7 +403,7 @@
}
} else {
var newNodes = BI.clone(nodes);
newNodes.pId = pId;
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId;
delete newNodes.children;
r.push(newNodes);
if (nodes["children"]) {
@ -414,21 +414,25 @@
},
arrayFormat: function (nodes, pId) {
if (!nodes) return [];
if (!nodes) {
return [];
}
var r = [];
if (BI.isArray(nodes)) {
for (var i = 0, l = nodes.length; i < l; i++) {
var node = nodes[i];
node.pId = node.pId == null ? pId : node.pId;
r.push(node);
if (nodes[i]["children"]) {
r = r.concat(BI.Tree.transformToArrayFormat(nodes[i]["children"], node.id));
r = r.concat(BI.Tree.arrayFormat(nodes[i]["children"], node.id));
}
}
} else {
var newNodes = nodes;
newNodes.pId = newNodes.pId == null ? pId : newNodes.pId;
r.push(newNodes);
if (nodes["children"]) {
r = r.concat(BI.Tree.transformToArrayFormat(nodes["children"], newNodes.id));
r = r.concat(BI.Tree.arrayFormat(nodes["children"], newNodes.id));
}
}
return r;
@ -444,13 +448,13 @@
var r = [];
var tmpMap = [];
for (i = 0, l = sNodes.length; i < l; i++) {
if(BI.isNull(sNodes[i].id)) {
if (BI.isNull(sNodes[i].id)) {
return sNodes;
}
tmpMap[sNodes[i].id] = BI.clone(sNodes[i]);
}
for (i = 0, l = sNodes.length; i < l; i++) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id != sNodes[i].pId) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) {
if (!tmpMap[sNodes[i].pId].children) {
tmpMap[sNodes[i].pId].children = [];
}
@ -466,6 +470,37 @@
}
},
treeFormat: function (sNodes) {
var i, l;
if (!sNodes) {
return [];
}
if (BI.isArray(sNodes)) {
var r = [];
var tmpMap = [];
for (i = 0, l = sNodes.length; i < l; i++) {
if (BI.isNull(sNodes[i].id)) {
return sNodes;
}
tmpMap[sNodes[i].id] = sNodes[i];
}
for (i = 0, l = sNodes.length; i < l; i++) {
if (tmpMap[sNodes[i].pId] && sNodes[i].id !== sNodes[i].pId) {
if (!tmpMap[sNodes[i].pId].children) {
tmpMap[sNodes[i].pId].children = [];
}
tmpMap[sNodes[i].pId].children.push(tmpMap[sNodes[i].id]);
} else {
r.push(tmpMap[sNodes[i].id]);
}
}
return r;
} else {
return [sNodes];
}
},
traversal: function (array, callback) {
if (BI.isNull(array)) {
return;

6
src/widget/multiselectlist/multiselectlist.js

@ -17,6 +17,7 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
var assertShowValue = function () {
BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue);
self.trigger.setValue(self.storeValue);
};
this.adapter = BI.createWidget({
@ -76,6 +77,8 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
self._showAdapter();
self._setStartValue("");
self.adapter.setValue(self.storeValue);
//需要刷新回到初始界面,否则搜索的结果不能放在最前面
self.adapter.populate();
}
}, {
eventName: BI.Searcher.EVENT_PAUSE,
@ -87,7 +90,6 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
value: [keyword]
}, function () {
self._showAdapter();
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
self._setStartValue(keyword);
assertShowValue();
@ -107,13 +109,11 @@ BI.MultiSelectList = BI.inherit(BI.Widget, {
if (keywords.length > 0) {
self._joinKeywords(keywords, function () {
if (BI.isEndWithBlank(last)) {
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
self.adapter.populate();
self._setStartValue("");
} else {
self.trigger.setValue(self.storeValue);
self.adapter.setValue(self.storeValue);
assertShowValue();
}

Loading…
Cancel
Save