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