Table: add column as third parameter for row-click event. (#1808)

This commit is contained in:
FuryBean 2016-12-17 14:00:35 +08:00 committed by cinwell.li
parent 12d43adeb3
commit 4614990cb4
4 changed files with 6 additions and 6 deletions

View File

@ -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 |

View File

@ -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 |

View File

@ -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);
}
}
};

View File

@ -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();