From 30c20d4e8a3a17ba491da21b10877fe50b6b87e0 Mon Sep 17 00:00:00 2001 From: tugcekucukoglu Date: Fri, 2 Feb 2024 23:17:35 +0300 Subject: [PATCH] Refactor #5196 --- components/lib/datatable/BodyRow.vue | 14 +++++++++++++- components/lib/datatable/style/DataTableStyle.js | 5 ++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/components/lib/datatable/BodyRow.vue b/components/lib/datatable/BodyRow.vue index 0366773cd..227b9e710 100644 --- a/components/lib/datatable/BodyRow.vue +++ b/components/lib/datatable/BodyRow.vue @@ -479,6 +479,7 @@ export default { }, rowClasses() { let rowStyleClass = []; + let columnSelectionMode = null; if (this.rowClass) { let rowClassValue = this.rowClass(this.rowData); @@ -488,7 +489,18 @@ export default { } } - return [this.cx('row', { rowData: this.rowData, index: this.rowIndex }), rowStyleClass]; + if (this.columns) { + for (let col of this.columns) { + let _selectionMode = this.columnProp(col, 'selectionMode'); + + if (ObjectUtils.isNotEmpty(_selectionMode) && _selectionMode === 'multiple') { + columnSelectionMode = _selectionMode; + break; + } + } + } + + return [this.cx('row', { rowData: this.rowData, index: this.rowIndex, columnSelectionMode }), rowStyleClass]; }, rowTabindex() { if (this.selection === null && (this.selectionMode === 'single' || this.selectionMode === 'multiple')) { diff --git a/components/lib/datatable/style/DataTableStyle.js b/components/lib/datatable/style/DataTableStyle.js index 8357189a1..a5df3ce41 100644 --- a/components/lib/datatable/style/DataTableStyle.js +++ b/components/lib/datatable/style/DataTableStyle.js @@ -350,7 +350,7 @@ const classes = { rowgroupHeader: 'p-rowgroup-header', rowGroupToggler: 'p-row-toggler p-link', rowGroupTogglerIcon: 'p-row-toggler-icon', - row: ({ instance, props, index }) => { + row: ({ instance, props, index, columnSelectionMode }) => { let rowStyleClass = []; if (props.selectionMode) { @@ -358,9 +358,8 @@ const classes = { } if (props.selection) { - console.log(props.selectionMode); rowStyleClass.push({ - 'p-highlight': props.selectionMode === 'multiple' || props.selectionMode === 'single' ? instance.isSelected : instance.isSelected && instance.$parentInstance.$parentInstance.highlightOnSelect + 'p-highlight': columnSelectionMode ? instance.isSelected && instance.$parentInstance.$parentInstance.highlightOnSelect : instance.isSelected }); }