From 208aaba527d6b22cbcc4b644206cada16b6cdd1b Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Mon, 9 Dec 2019 11:37:20 +0300 Subject: [PATCH] Refactor --- src/components/datatable/DataTable.vue | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/datatable/DataTable.vue b/src/components/datatable/DataTable.vue index b6f6c4be5..37256c2b8 100644 --- a/src/components/datatable/DataTable.vue +++ b/src/components/datatable/DataTable.vue @@ -621,7 +621,6 @@ export default { onRowClick(e) { const event = e.originalEvent; const target = event.target; - const rowIndex = event.index; const targetNode = target.nodeName; const parentNode = target.parentElement && target.parentElement.nodeName; @@ -661,7 +660,7 @@ export default { this.$emit('update:selection', _selection); } - this.$emit('row-unselect', {originalEvent: event, data: rowData, index: rowIndex, type: 'row'}); + this.$emit('row-unselect', {originalEvent: event, data: rowData, index: event.index, type: 'row'}); } else { if(this.isSingleSelectionMode()) { @@ -673,18 +672,18 @@ export default { this.$emit('update:selection', _selection); } - this.$emit('row-select', {originalEvent: event, data: rowData, index: rowIndex, type: 'row'}); + this.$emit('row-select', {originalEvent: event, data: rowData, index: event.index, type: 'row'}); } } else { if (this.selectionMode === 'single') { if (selected) { this.$emit('update:selection', null); - this.$emit('row-unselect', {originalEvent: event, data: rowData, index: rowIndex, type: 'row'}); + this.$emit('row-unselect', {originalEvent: event, data: rowData, index: event.index, type: 'row'}); } else { this.$emit('update:selection', rowData); - this.$emit('row-select', {originalEvent: event, data: rowData, index: rowIndex, type: 'row'}); + this.$emit('row-select', {originalEvent: event, data: rowData, index: event.index, type: 'row'}); } } else if (this.selectionMode === 'multiple') { @@ -692,12 +691,12 @@ export default { const selectionIndex = this.findIndexInSelection(rowData); const _selection = this.selection.filter((val, i) => i != selectionIndex); this.$emit('update:selection', _selection); - this.$emit('row-unselect', {originalEvent: event, data: rowData, index: rowIndex, type: 'row'}); + this.$emit('row-unselect', {originalEvent: event, data: rowData, index: event.index, type: 'row'}); } else { const _selection = this.selection ? [...this.selection, rowData] : [rowData]; this.$emit('update:selection', _selection); - this.$emit('row-select', {originalEvent: event, data: rowData, index: rowIndex, type: 'row'}); + this.$emit('row-select', {originalEvent: event, data: rowData, index: event.index, type: 'row'}); } } }