From b27169098eba87e6d86af542d7e3ae4a9a45fc58 Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Wed, 20 Nov 2019 12:56:44 +0300 Subject: [PATCH] Fixed #82 - Add row-click event to Table --- src/components/datatable/DataTable.vue | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/components/datatable/DataTable.vue b/src/components/datatable/DataTable.vue index a819aba61..a28959e7b 100644 --- a/src/components/datatable/DataTable.vue +++ b/src/components/datatable/DataTable.vue @@ -616,19 +616,21 @@ export default { }, onRowClick(e) { const event = e.originalEvent; - const rowData = e.data; - const rowIndex = e.index; + const target = event.target; + const targetNode = target.nodeName; + const parentNode = target.parentElement && target.parentElement.nodeName; + if (targetNode == 'INPUT' || targetNode == 'BUTTON' || targetNode == 'A' || + parentNode == 'INPUT' || parentNode == 'BUTTON' || parentNode == 'A' || + (DomHandler.hasClass(target, 'p-clickable'))) { + return; + } + + this.$emit('row-click', event); + if (this.selectionMode) { - let target = event.target; - let targetNode = target.nodeName; - let parentNode = target.parentElement && target.parentElement.nodeName; - - if (targetNode == 'INPUT' || targetNode == 'BUTTON' || targetNode == 'A' || - parentNode == 'INPUT' || parentNode == 'BUTTON' || parentNode == 'A' || - (DomHandler.hasClass(target, 'p-clickable'))) { - return; - } + const rowData = e.data; + const rowIndex = e.index; if (this.isMultipleSelectionMode() && event.shiftKey && this.anchorRowIndex != null) { DomHandler.clearSelection();