Fixed #2068 - DataTable row-select index is always undefined
parent
227623f3b3
commit
2fb44329a8
|
@ -8,8 +8,8 @@
|
|||
<component :is="column.children.editor" :data="editingRowData" :column="column" :field="field" :index="rowIndex" :frozenRow="frozenRow" v-else-if="column.children && column.children.editor && d_editing" />
|
||||
<component :is="column.children.body" :data="editingRowData" :column="column" :field="field" :index="rowIndex" :frozenRow="frozenRow" v-else-if="column.children && column.children.body && !column.children.editor && d_editing" />
|
||||
<template v-else-if="columnProp('selectionMode')">
|
||||
<DTRadioButton :value="rowData" :checked="selected" @change="toggleRowWithRadio" v-if="columnProp('selectionMode') === 'single'" />
|
||||
<DTCheckbox :value="rowData" :checked="selected" @change="toggleRowWithCheckbox" v-else-if="columnProp('selectionMode') ==='multiple'" />
|
||||
<DTRadioButton :value="rowData" :checked="selected" @change="toggleRowWithRadio($event, rowIndex)" v-if="columnProp('selectionMode') === 'single'" />
|
||||
<DTCheckbox :value="rowData" :checked="selected" @change="toggleRowWithCheckbox($event, rowIndex)" v-else-if="columnProp('selectionMode') ==='multiple'" />
|
||||
</template>
|
||||
<template v-else-if="columnProp('rowReorder')">
|
||||
<i :class="['p-datatable-reorderablerow-handle', (columnProp('rowReorderIcon') || 'pi pi-bars')]"></i>
|
||||
|
@ -146,11 +146,11 @@ export default {
|
|||
data: this.rowData
|
||||
});
|
||||
},
|
||||
toggleRowWithRadio(event) {
|
||||
this.$emit('radio-change', event);
|
||||
toggleRowWithRadio(event, index) {
|
||||
this.$emit('radio-change', { originalEvent: event.originalEvent, index: index, data: event.data});
|
||||
},
|
||||
toggleRowWithCheckbox(event) {
|
||||
this.$emit('checkbox-change', event);
|
||||
toggleRowWithCheckbox(event, index) {
|
||||
this.$emit('checkbox-change', { originalEvent: event.originalEvent, index: index, data: event.data });
|
||||
},
|
||||
isEditable() {
|
||||
return this.column.children && this.column.children.editor != null;
|
||||
|
|
|
@ -731,7 +731,7 @@ export default {
|
|||
this.$emit('update:selection', _selection);
|
||||
}
|
||||
|
||||
this.$emit('row-unselect', {originalEvent: event, data: rowData, index: event.index, type: 'row'});
|
||||
this.$emit('row-unselect', {originalEvent: event, data: rowData, index: rowIndex, type: 'row'});
|
||||
}
|
||||
else {
|
||||
if(this.isSingleSelectionMode()) {
|
||||
|
@ -743,18 +743,18 @@ export default {
|
|||
this.$emit('update:selection', _selection);
|
||||
}
|
||||
|
||||
this.$emit('row-select', {originalEvent: event, data: rowData, index: event.index, type: 'row'});
|
||||
this.$emit('row-select', {originalEvent: event, data: rowData, index: rowIndex, type: 'row'});
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this.selectionMode === 'single') {
|
||||
if (selected) {
|
||||
this.$emit('update:selection', null);
|
||||
this.$emit('row-unselect', {originalEvent: event, data: rowData, index: event.index, type: 'row'});
|
||||
this.$emit('row-unselect', {originalEvent: event, data: rowData, index: rowIndex, type: 'row'});
|
||||
}
|
||||
else {
|
||||
this.$emit('update:selection', rowData);
|
||||
this.$emit('row-select', {originalEvent: event, data: rowData, index: event.index, type: 'row'});
|
||||
this.$emit('row-select', {originalEvent: event, data: rowData, index: rowIndex, type: 'row'});
|
||||
}
|
||||
}
|
||||
else if (this.selectionMode === 'multiple') {
|
||||
|
@ -762,12 +762,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: event.index, type: 'row'});
|
||||
this.$emit('row-unselect', {originalEvent: event, data: rowData, index: rowIndex, 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: event.index, type: 'row'});
|
||||
this.$emit('row-select', {originalEvent: event, data: rowData, index: rowIndex, type: 'row'});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -863,11 +863,11 @@ export default {
|
|||
|
||||
if (this.isSelected(rowData)) {
|
||||
this.$emit('update:selection', null);
|
||||
this.$emit('row-unselect', {originalEvent: event, data: rowData, type: 'radiobutton'});
|
||||
this.$emit('row-unselect', { originalEvent: event.originalEvent, data: rowData, index: event.index, type: 'radiobutton' });
|
||||
}
|
||||
else {
|
||||
this.$emit('update:selection', rowData);
|
||||
this.$emit('row-select', {originalEvent: event, data: rowData, type: 'radiobutton'});
|
||||
this.$emit('row-select', { originalEvent: event.originalEvent, data: rowData, index: event.index, type: 'radiobutton' });
|
||||
}
|
||||
},
|
||||
toggleRowWithCheckbox(event) {
|
||||
|
@ -877,13 +877,13 @@ 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, type: 'checkbox'});
|
||||
this.$emit('row-unselect', { originalEvent: event.originalEvent, data: rowData, index: event.index, type: 'checkbox' });
|
||||
}
|
||||
else {
|
||||
let _selection = this.selection ? [...this.selection] : [];
|
||||
_selection = [..._selection, rowData];
|
||||
this.$emit('update:selection', _selection);
|
||||
this.$emit('row-select', {originalEvent: event, data: rowData, type: 'checkbox'});
|
||||
this.$emit('row-select', { originalEvent: event.originalEvent, data: rowData, index: event.index, type: 'checkbox' });
|
||||
}
|
||||
},
|
||||
toggleRowsWithCheckbox(event) {
|
||||
|
|
Loading…
Reference in New Issue