Skip to content

Commit

Permalink
Refactor #5196
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Feb 2, 2024
1 parent 3a89a10 commit 30c20d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 13 additions & 1 deletion components/lib/datatable/BodyRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ export default {
},
rowClasses() {
let rowStyleClass = [];
let columnSelectionMode = null;
if (this.rowClass) {
let rowClassValue = this.rowClass(this.rowData);
Expand All @@ -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')) {
Expand Down
5 changes: 2 additions & 3 deletions components/lib/datatable/style/DataTableStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,16 @@ 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) {
rowStyleClass.push('p-selectable-row');
}

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

Expand Down

0 comments on commit 30c20d4

Please sign in to comment.