|
|
|
@ -30,7 +30,7 @@ export default class GridView extends Widget {
|
|
|
|
|
scrollLeft: 0, |
|
|
|
|
scrollTop: 0, |
|
|
|
|
items: [], |
|
|
|
|
itemFormatter: (item, row, col)=> { |
|
|
|
|
itemFormatter: (item, row, col) => { |
|
|
|
|
return item; |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
@ -46,13 +46,13 @@ export default class GridView extends Widget {
|
|
|
|
|
this.renderedKeys = []; |
|
|
|
|
this.renderRange = {}; |
|
|
|
|
this._scrollLock = false; |
|
|
|
|
this._debounceRelease = BI.debounce(()=> { |
|
|
|
|
this._debounceRelease = BI.debounce(() => { |
|
|
|
|
this._scrollLock = false; |
|
|
|
|
}, 1000 / 60); |
|
|
|
|
this.container = BI._lazyCreateWidget({ |
|
|
|
|
type: "bi.absolute", |
|
|
|
|
}); |
|
|
|
|
this.element.scroll(()=> { |
|
|
|
|
this.element.scroll(() => { |
|
|
|
|
if (this._scrollLock === true) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -85,7 +85,7 @@ export default class GridView extends Widget {
|
|
|
|
|
scrollx: scrollx, |
|
|
|
|
items: [this.container], |
|
|
|
|
}); |
|
|
|
|
o.items = BI.isFunction(o.items) ? this.__watch(o.items, (context, newValue)=> { |
|
|
|
|
o.items = BI.isFunction(o.items) ? this.__watch(o.items, (context, newValue) => { |
|
|
|
|
this.populate(newValue); |
|
|
|
|
}) : o.items; |
|
|
|
|
if (o.items.length > 0) { |
|
|
|
@ -104,7 +104,7 @@ export default class GridView extends Widget {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
destroyed() { |
|
|
|
|
BI.each(this.renderedCells, (i, cell)=> { |
|
|
|
|
BI.each(this.renderedCells, (i, cell) => { |
|
|
|
|
cell.el._destroy(); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
@ -235,14 +235,14 @@ export default class GridView extends Widget {
|
|
|
|
|
} |
|
|
|
|
// 已存在的, 需要添加的和需要删除的
|
|
|
|
|
const existSet = {}, addSet = {}, deleteArray = []; |
|
|
|
|
BI.each(renderedKeys, (i, key)=> { |
|
|
|
|
BI.each(renderedKeys, (i, key) => { |
|
|
|
|
if (this.renderedKeys[i]) { |
|
|
|
|
existSet[i] = key; |
|
|
|
|
} else { |
|
|
|
|
addSet[i] = key; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
BI.each(this.renderedKeys, function (i, key) { |
|
|
|
|
BI.each(this.renderedKeys, (i, key) => { |
|
|
|
|
if (existSet[i]) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -251,12 +251,12 @@ export default class GridView extends Widget {
|
|
|
|
|
} |
|
|
|
|
deleteArray.push(key[2]); |
|
|
|
|
}); |
|
|
|
|
BI.each(deleteArray, (i, index)=> { |
|
|
|
|
BI.each(deleteArray, (i, index) => { |
|
|
|
|
// 性能优化,不调用destroy方法防止触发destroy事件
|
|
|
|
|
this.renderedCells[index].el._destroy(); |
|
|
|
|
}); |
|
|
|
|
const addedItems = []; |
|
|
|
|
BI.each(addSet, function (index, key) { |
|
|
|
|
BI.each(addSet, (index, key) => { |
|
|
|
|
addedItems.push(renderedCells[key[2]]); |
|
|
|
|
}); |
|
|
|
|
// 与listview一样, 给上下文
|
|
|
|
@ -370,7 +370,7 @@ export default class GridView extends Widget {
|
|
|
|
|
setOverflowX(b) { |
|
|
|
|
if (this.options.overflowX !== !!b) { |
|
|
|
|
this.options.overflowX = !!b; |
|
|
|
|
BI.nextTick(()=> { |
|
|
|
|
BI.nextTick(() => { |
|
|
|
|
this.element.css({ overflowX: b ? "auto" : "hidden" }); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -379,7 +379,7 @@ export default class GridView extends Widget {
|
|
|
|
|
setOverflowY(b) { |
|
|
|
|
if (this.options.overflowY !== !!b) { |
|
|
|
|
this.options.overflowY = !!b; |
|
|
|
|
BI.nextTick(()=> { |
|
|
|
|
BI.nextTick(() => { |
|
|
|
|
this.element.css({ overflowY: b ? "auto" : "hidden" }); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -418,7 +418,7 @@ export default class GridView extends Widget {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
restore() { |
|
|
|
|
BI.each(this.renderedCells, (i, cell)=> { |
|
|
|
|
BI.each(this.renderedCells, (i, cell) => { |
|
|
|
|
cell.el._destroy(); |
|
|
|
|
}); |
|
|
|
|
this._clearChildren(); |
|
|
|
|