update Table
update Table
This commit is contained in:
parent
3ef4dfb9ef
commit
7f34c51030
6 changed files with 149 additions and 89 deletions
|
@ -17,7 +17,8 @@
|
|||
row: Object,
|
||||
column: Object,
|
||||
index: Number,
|
||||
checked: Boolean
|
||||
checked: Boolean,
|
||||
fixed: Boolean
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
|
@ -30,7 +31,7 @@
|
|||
return [
|
||||
`${this.prefixCls}-cell`,
|
||||
{
|
||||
[`${this.prefixCls}-hidden`]: this.column.fixed && (this.column.fixed === 'left' || this.column.fixed === 'right')
|
||||
[`${this.prefixCls}-hidden`]: !this.fixed && this.column.fixed && (this.column.fixed === 'left' || this.column.fixed === 'right')
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -38,29 +39,31 @@
|
|||
methods: {
|
||||
compile () {
|
||||
if (this.column.render) {
|
||||
const $parent = this.$parent.$parent.$parent;
|
||||
const template = this.column.render(this.row, this.column, this.index);
|
||||
const cell = document.createElement('div');
|
||||
cell.innerHTML = template;
|
||||
const _oldParentChildLen = this.$parent.$parent.$children.length;
|
||||
this.$parent.$parent.$compile(cell);
|
||||
const _newParentChildLen = this.$parent.$parent.$children.length;
|
||||
const _oldParentChildLen = $parent.$children.length;
|
||||
$parent.$compile(cell);
|
||||
const _newParentChildLen = $parent.$children.length;
|
||||
|
||||
if (_oldParentChildLen !== _newParentChildLen) { // if render normal html node, do not tag
|
||||
this.uid = this.$parent.$parent.$children[this.$parent.$parent.$children.length - 1]._uid; // tag it, and delete when data or columns update
|
||||
this.uid = $parent.$children[$parent.$children.length - 1]._uid; // tag it, and delete when data or columns update
|
||||
}
|
||||
this.$el.innerHTML = '';
|
||||
this.$el.appendChild(cell);
|
||||
}
|
||||
},
|
||||
destroy () {
|
||||
for (let i = 0; i < this.$parent.$parent.$children.length; i++) {
|
||||
if (this.$parent.$parent.$children[i]._uid === this.uid) {
|
||||
this.$parent.$parent.$children[i].$destroy();
|
||||
const $parent = this.$parent.$parent.$parent;
|
||||
for (let i = 0; i < $parent.$children.length; i++) {
|
||||
if ($parent.$children[i]._uid === this.uid) {
|
||||
$parent.$children[i].$destroy();
|
||||
}
|
||||
}
|
||||
},
|
||||
toggleSelect (index) {
|
||||
this.$parent.toggleSelect(index);
|
||||
this.$parent.$parent.toggleSelect(index);
|
||||
}
|
||||
},
|
||||
compiled () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue