From 4614990cb42d27f90773abbb360a12b7663361ff Mon Sep 17 00:00:00 2001 From: FuryBean Date: Sat, 17 Dec 2016 14:00:35 +0800 Subject: [PATCH] Table: add column as third parameter for row-click event. (#1808) --- examples/docs/en-US/table.md | 2 +- examples/docs/zh-CN/table.md | 2 +- packages/table/src/table-body.js | 6 +++--- test/unit/specs/table.spec.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/docs/en-US/table.md b/examples/docs/en-US/table.md index edc604d3..7dd4802a 100644 --- a/examples/docs/en-US/table.md +++ b/examples/docs/en-US/table.md @@ -1380,7 +1380,7 @@ Customize table column so it can be integrated with other components. | cell-mouse-enter | triggers when hovering into a cell| row, column, cell, event | | cell-mouse-leave | triggers when hovering out of a cell | row, column, cell, event | | cell-click | triggers when clicking a cell | row, column, cell, event | -| row-click | triggers when clicking a row | row, event | +| row-click | triggers when clicking a row | row, event, column | | row-contextmenu | triggers when user right clicks on a row | row, event | | row-dblclick | triggers when double clicking a row | row, event | | header-click | triggers when clicking a column header | column, event | diff --git a/examples/docs/zh-CN/table.md b/examples/docs/zh-CN/table.md index 65931aff..729b3986 100644 --- a/examples/docs/zh-CN/table.md +++ b/examples/docs/zh-CN/table.md @@ -1388,7 +1388,7 @@ | cell-mouse-enter | 当单元格 hover 进入时会触发该事件 | row, column, cell, event | | cell-mouse-leave | 当单元格 hover 退出时会触发该事件 | row, column, cell, event | | cell-click | 当某个单元格被点击时会触发该事件 | row, column, cell, event | -| row-click | 当某一行被点击时会触发该事件 | row, event | +| row-click | 当某一行被点击时会触发该事件 | row, event, column | | row-contextmenu | 当某一行被鼠标右键点击时会触发该事件 | row, event | | row-dblclick | 当某一行被双击时会触发该事件 | row, event | | header-click | 当某一列的表头被点击时会触发该事件 | column, event | diff --git a/packages/table/src/table-body.js b/packages/table/src/table-body.js index 38d6d9cc..88000899 100644 --- a/packages/table/src/table-body.js +++ b/packages/table/src/table-body.js @@ -215,9 +215,9 @@ export default { handleClick(event, row) { const table = this.$parent; const cell = getCell(event); - + let column; if (cell) { - const column = getColumnByCell(table, cell); + column = getColumnByCell(table, cell); if (column) { table.$emit('cell-click', row, column, cell, event); } @@ -225,7 +225,7 @@ export default { this.store.commit('setCurrentRow', row); - table.$emit('row-click', row, event); + table.$emit('row-click', row, event, column); } } }; diff --git a/test/unit/specs/table.spec.js b/test/unit/specs/table.spec.js index 17818011..324e6559 100644 --- a/test/unit/specs/table.spec.js +++ b/test/unit/specs/table.spec.js @@ -401,7 +401,7 @@ describe('Table', () => { const cell = vm.$el.querySelectorAll('.el-table__body .cell')[2]; // first row triggerEvent(cell.parentNode.parentNode, 'click'); - expect(vm.result).to.length(2); // row, event + expect(vm.result).to.length(3); // row, event, column expect(vm.result[0]).to.have.property('name').to.equal(getTestData()[0].name); destroyVM(vm); done();