V3 migration for Table Reordering

pull/496/head
Cagatay Civici 2020-09-24 11:05:14 +03:00
parent 8164fbe703
commit effb19203a
2 changed files with 5 additions and 11 deletions

View File

@ -7,7 +7,7 @@
<DTCheckbox :value="rowData" :checked="selected" @change="toggleRowWithCheckbox" v-else-if="column.props.selectionMode ==='multiple'" /> <DTCheckbox :value="rowData" :checked="selected" @change="toggleRowWithCheckbox" v-else-if="column.props.selectionMode ==='multiple'" />
</template> </template>
<template v-else-if="column.props.rowReorder"> <template v-else-if="column.props.rowReorder">
<i :class="['p-datatable-reorderablerow-handle', column.props.rowReorderIcon]"></i> <i :class="['p-datatable-reorderablerow-handle', (column.props.rowReorderIcon || 'pi pi-bars')]"></i>
</template> </template>
<template v-else-if="column.props.expander"> <template v-else-if="column.props.expander">
<button class="p-row-toggler p-link" @click="toggleRow" type="button" v-ripple> <button class="p-row-toggler p-link" @click="toggleRow" type="button" v-ripple>

View File

@ -433,13 +433,9 @@ export default {
mounted() { mounted() {
if (this.reorderableColumns) { if (this.reorderableColumns) {
let columnOrder = []; let columnOrder = [];
const children = this.$slots.default(); this.columns.forEach(col => columnOrder.push(col.props.columnKey||col.props.field));
for (let child of children) {
if (child.type.name === 'column') {
columnOrder.push(child.props.columnKey||child.props.field);
}
}
this.d_columnOrder = columnOrder; this.d_columnOrder = columnOrder;
console.log()
} }
}, },
beforeUnmount() { beforeUnmount() {
@ -1136,7 +1132,7 @@ export default {
const event = e.originalEvent; const event = e.originalEvent;
const column = e.column; const column = e.column;
if (this.reorderableColumns && column.reorderableColumn) { if (this.reorderableColumns && column.props.reorderableColumn !== false) {
if (event.target.nodeName === 'INPUT' || event.target.nodeName === 'TEXTAREA' || DomHandler.hasClass(event.target, 'p-column-resizer')) if (event.target.nodeName === 'INPUT' || event.target.nodeName === 'TEXTAREA' || DomHandler.hasClass(event.target, 'p-column-resizer'))
event.currentTarget.draggable = false; event.currentTarget.draggable = false;
else else
@ -1670,9 +1666,7 @@ export default {
} }
} }
return [...orderedColumns, ...cols.filter((item) => { return [...orderedColumns, ...cols.filter((item) => orderedColumns.indexOf(item) < 0)];
return orderedColumns.indexOf(item) < 0;
})];
} }
return cols; return cols;