Browse Source

feature: 选中数据支持分页

es6
guy 3 years ago
parent
commit
b2fc2f50e3
  1. 43
      src/widget/multiselect/multiselect.loader.nobar.js

43
src/widget/multiselect/multiselect.loader.nobar.js

@ -55,22 +55,23 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, {
}, },
itemsCreator: function (op, callback) { itemsCreator: function (op, callback) {
var startValue = self._startValue; var startValue = self._startValue;
var firstItems = [];
self.storeValue && (op = BI.extend(op || {}, { self.storeValue && (op = BI.extend(op || {}, {
selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi
? self.storeValue.value.concat(startValue) : self.storeValue.value ? self.storeValue.value.concat(startValue) : self.storeValue.value
})); }));
if (self.storeValue) { opts.itemsCreator(op, function (ob) {
var json = BI.map(self.storeValue.value.slice((op.times - 1) * 100, op.times * 100), function (i, v) { hasNext = ob.hasNext;
var txt = opts.valueFormatter(v) || v; var firstItems = [];
return { if (op.times === 1 && self.storeValue) {
text: txt, var json = BI.map(self.storeValue.value, function (i, v) {
value: v, var txt = opts.valueFormatter(v) || v;
title: txt, return {
selected: self.storeValue.type === BI.Selection.Multi text: txt,
}; value: v,
}); title: txt,
if (op.times === 1) { selected: self.storeValue.type === BI.Selection.Multi
};
});
if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) { if (BI.isKey(self._startValue) && !BI.contains(self.storeValue.value, self._startValue)) {
var txt = opts.valueFormatter(startValue) || startValue; var txt = opts.valueFormatter(startValue) || startValue;
json.unshift({ json.unshift({
@ -80,22 +81,10 @@ BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, {
selected: true selected: true
}); });
} }
firstItems = self._createItems(json);
} }
if (op.times < Math.floor((self.storeValue.value.length - 1) / 100)) { callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || "");
hasNext = true; if (op.times === 1 && self.storeValue) {
callback(self._createItems(json), op.keyword || "");
(op.times === 1) && self._scrollToTop();
return;
}
firstItems = self._createItems(json);
}
var times = op.times - Math.max(0, Math.floor((self.storeValue.value.length - 1) / 100));
opts.itemsCreator(BI.extend({}, op, {
times: times
}), function (ob) {
hasNext = ob.hasNext;
callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || op.keyword || "");
if (times === 1 && self.storeValue) {
BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue)); BI.isKey(startValue) && (self.storeValue.type === BI.Selection.All ? BI.remove(self.storeValue.value, startValue) : BI.pushDistinct(self.storeValue.value, startValue));
self.setValue(self.storeValue); self.setValue(self.storeValue);
} }

Loading…
Cancel
Save