Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
levy committed Feb 10, 2020
2 parents 81c18c3 + 1ab51ed commit 4f2f789
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/is-tree.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,17 @@ export default {
],
hasPagination: false,
isTree: true,
tableAttrs: {
rowClassName({rowIndex}) {
return rowIndex === 2 ? 'is-tree-red' : ''
}
},
expandAll: true,
}
},
created() {
// FYI: styleguide 里面用不了 style block
document.querySelector('style').sheet.insertRule('.is-tree-red {color: red}')
}
}
</script>
Expand Down
9 changes: 8 additions & 1 deletion src/el-data-table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
v-loading="loading"
v-bind="tableAttrs"
:data="data"
:row-class-name="showRow"
:row-class-name="rowClassName"
@selection-change="selectStrategy.onSelectionChange"
@select="selectStrategy.onSelect"
@select-all="selectStrategy.onSelectAll($event, selectable)"
Expand Down Expand Up @@ -1220,6 +1220,13 @@ export default {
})
return tmp
},
rowClassName(...args) {
let rcn =
this.tableAttrs.rowClassName || this.tableAttrs['row-class-name'] || ''
if (typeof rcn === 'function') rcn = rcn(...args)
if (this.isTree) rcn += ' ' + this.showRow(...args)
return rcn
},
showRow({row}) {
const show = !row.parent || (row.parent._expanded && row.parent._show)
row._show = show
Expand Down

0 comments on commit 4f2f789

Please sign in to comment.