Edit demo update
parent
1ebf30b229
commit
a9d38ffca3
|
@ -16,12 +16,12 @@
|
||||||
<DataTable :value="products1" editMode="cell" class="editable-cells-table">
|
<DataTable :value="products1" editMode="cell" class="editable-cells-table">
|
||||||
<Column field="code" header="Code">
|
<Column field="code" header="Code">
|
||||||
<template #editor="slotProps">
|
<template #editor="slotProps">
|
||||||
<InputText v-model="slotProps.data[slotProps.column.field]" />
|
<InputText v-model="slotProps.data[slotProps.column.props.field]" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="name" header="Name">
|
<Column field="name" header="Name">
|
||||||
<template #editor="slotProps">
|
<template #editor="slotProps">
|
||||||
<InputText v-model="slotProps.data[slotProps.column.field]" />
|
<InputText v-model="slotProps.data[slotProps.column.props.field]" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="inventoryStatus" header="Status">
|
<Column field="inventoryStatus" header="Status">
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="price" header="Price">
|
<Column field="price" header="Price">
|
||||||
<template #editor="slotProps">
|
<template #editor="slotProps">
|
||||||
<InputText v-model="slotProps.data[slotProps.column.field]" />
|
<InputText v-model="slotProps.data[slotProps.column.props.field]" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
@ -47,10 +47,10 @@
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5>Advanced Cell Editing</h5>
|
<h5>Advanced Cell Editing</h5>
|
||||||
<p>Custom implementation with validations, dynamic columns and reverting values with the escape key.</p>
|
<p>Custom implementation with validations, dynamic columns and reverting values with the escape key.</p>
|
||||||
<DataTable :value="products2" editMode="cell" @cell-edit-complete="onCellEditComplete" class="editable-cells-table">
|
<DataTable :value="products2" editMode="cell" @cell-edit-complete="onCellEditComplete" class="editable-cells-table" >
|
||||||
<Column v-for="col of columns" :field="col.field" :header="col.header" :key="col.field">
|
<Column v-for="col of columns" :field="col.field" :header="col.header" :key="col.field">
|
||||||
<template #editor="slotProps">
|
<template #editor="slotProps">
|
||||||
<InputText :value="slotProps.data[slotProps.column.field]" @input="onCellEdit($event, slotProps)" />
|
<InputText :modelValue="slotProps.data[slotProps.column.props.field]" @update:modelValue="onCellEdit($event, slotProps)" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
@ -62,12 +62,12 @@
|
||||||
@row-edit-init="onRowEditInit" @row-edit-cancel="onRowEditCancel">
|
@row-edit-init="onRowEditInit" @row-edit-cancel="onRowEditCancel">
|
||||||
<Column field="code" header="Code">
|
<Column field="code" header="Code">
|
||||||
<template #editor="slotProps">
|
<template #editor="slotProps">
|
||||||
<InputText v-model="slotProps.data[slotProps.column.field]" autofocus />
|
<InputText v-model="slotProps.data[slotProps.column.props.field]" autofocus />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="name" header="Name">
|
<Column field="name" header="Name">
|
||||||
<template #editor="slotProps">
|
<template #editor="slotProps">
|
||||||
<InputText v-model="slotProps.data[slotProps.column.field]" />
|
<InputText v-model="slotProps.data[slotProps.column.props.field]" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="inventoryStatus" header="Status">
|
<Column field="inventoryStatus" header="Status">
|
||||||
|
@ -84,7 +84,7 @@
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="price" header="Price">
|
<Column field="price" header="Price">
|
||||||
<template #editor="slotProps">
|
<template #editor="slotProps">
|
||||||
<InputText v-model="slotProps.data[slotProps.column.field]" />
|
<InputText v-model="slotProps.data[slotProps.column.props.field]" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column :rowEditor="true" headerStyle="width:7rem" bodyStyle="text-align:center"></Column>
|
<Column :rowEditor="true" headerStyle="width:7rem" bodyStyle="text-align:center"></Column>
|
||||||
|
@ -97,18 +97,17 @@
|
||||||
<TabPanel header="Source">
|
<TabPanel header="Source">
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
<div class="card">
|
<h5>Basic Cell Editing</h5>
|
||||||
<h5>Basic Cell Editing</h5>
|
<p>Simple editors with v-model.</p>
|
||||||
<p>Simple editors with v-model.</p>
|
<DataTable :value="products1" editMode="cell" class="editable-cells-table">
|
||||||
<DataTable :value="products1" editMode="cell" class="editable-cells-table">
|
|
||||||
<Column field="code" header="Code">
|
<Column field="code" header="Code">
|
||||||
<template #editor="slotProps">
|
<template #editor="slotProps">
|
||||||
<InputText v-model="slotProps.data[slotProps.column.field]" />
|
<InputText v-model="slotProps.data[slotProps.column.props.field]" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="name" header="Name">
|
<Column field="name" header="Name">
|
||||||
<template #editor="slotProps">
|
<template #editor="slotProps">
|
||||||
<InputText v-model="slotProps.data[slotProps.column.field]" />
|
<InputText v-model="slotProps.data[slotProps.column.props.field]" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="inventoryStatus" header="Status">
|
<Column field="inventoryStatus" header="Status">
|
||||||
|
@ -125,36 +124,36 @@
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="price" header="Price">
|
<Column field="price" header="Price">
|
||||||
<template #editor="slotProps">
|
<template #editor="slotProps">
|
||||||
<InputText v-model="slotProps.data[slotProps.column.field]" />
|
<InputText v-model="slotProps.data[slotProps.column.props.field]" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5>Advanced Cell Editing</h5>
|
<h5>Advanced Cell Editing</h5>
|
||||||
<p>Custom implementation with validations, dynamic columns and reverting values with the escape key.</p>
|
<p>Custom implementation with validations, dynamic columns and reverting values with the escape key.</p>
|
||||||
<DataTable :value="products2" editMode="cell" @cell-edit-complete="onCellEditComplete" class="editable-cells-table">
|
<DataTable :value="products2" editMode="cell" @cell-edit-complete="onCellEditComplete" class="editable-cells-table" >
|
||||||
<Column v-for="col of columns" :field="col.field" :header="col.header" :key="col.field">
|
<Column v-for="col of columns" :field="col.field" :header="col.header" :key="col.field">
|
||||||
<template #editor="slotProps">
|
<template #editor="slotProps">
|
||||||
<InputText :value="slotProps.data[slotProps.column.field]" @input="onCellEdit($event, slotProps)" />
|
<InputText :modelValue="slotProps.data[slotProps.column.props.field]" @update:modelValue="onCellEdit($event, slotProps)" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h5>Row Editing</h5>
|
<h5>Row Editing</h5>
|
||||||
<DataTable :value="products3" editMode="row" dataKey="id" :editingRows.sync="editingRows"
|
<DataTable :value="products3" editMode="row" dataKey="id" v-model:editingRows="editingRows"
|
||||||
@row-edit-init="onRowEditInit" @row-edit-cancel="onRowEditCancel">
|
@row-edit-init="onRowEditInit" @row-edit-cancel="onRowEditCancel">
|
||||||
<Column field="code" header="Code">
|
<Column field="code" header="Code">
|
||||||
<template #editor="slotProps">
|
<template #editor="slotProps">
|
||||||
<InputText v-model="slotProps.data[slotProps.column.field]" autofocus />
|
<InputText v-model="slotProps.data[slotProps.column.props.field]" autofocus />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="name" header="Name">
|
<Column field="name" header="Name">
|
||||||
<template #editor="slotProps">
|
<template #editor="slotProps">
|
||||||
<InputText v-model="slotProps.data[slotProps.column.field]" />
|
<InputText v-model="slotProps.data[slotProps.column.props.field]" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="inventoryStatus" header="Status">
|
<Column field="inventoryStatus" header="Status">
|
||||||
|
@ -171,18 +170,16 @@
|
||||||
</Column>
|
</Column>
|
||||||
<Column field="price" header="Price">
|
<Column field="price" header="Price">
|
||||||
<template #editor="slotProps">
|
<template #editor="slotProps">
|
||||||
<InputText v-model="slotProps.data[slotProps.column.field]" />
|
<InputText v-model="slotProps.data[slotProps.column.props.field]" />
|
||||||
</template>
|
</template>
|
||||||
</Column>
|
</Column>
|
||||||
<Column :rowEditor="true" headerStyle="width:7rem" bodyStyle="text-align:center"></Column>
|
<Column :rowEditor="true" headerStyle="width:7rem" bodyStyle="text-align:center"></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
<CodeHighlight lang="javascript">
|
<CodeHighlight lang="javascript">
|
||||||
import ProductService from '../../service/ProductService';
|
import ProductService from '../../service/ProductService';
|
||||||
import Vue from 'vue';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -240,7 +237,7 @@ export default {
|
||||||
this.editingCellRows[props.index] = {...props.data};
|
this.editingCellRows[props.index] = {...props.data};
|
||||||
}
|
}
|
||||||
|
|
||||||
this.editingCellRows[props.index][props.column.field] = newValue;
|
this.editingCellRows[props.index][props.column.props.field] = newValue;
|
||||||
},
|
},
|
||||||
isPositiveInteger(val) {
|
isPositiveInteger(val) {
|
||||||
let str = String(val);
|
let str = String(val);
|
||||||
|
@ -353,7 +350,7 @@ export default {
|
||||||
this.editingCellRows[props.index] = {...props.data};
|
this.editingCellRows[props.index] = {...props.data};
|
||||||
}
|
}
|
||||||
|
|
||||||
this.editingCellRows[props.index][props.column.field] = newValue;
|
this.editingCellRows[props.index][props.column.props.field] = newValue;
|
||||||
},
|
},
|
||||||
isPositiveInteger(val) {
|
isPositiveInteger(val) {
|
||||||
let str = String(val);
|
let str = String(val);
|
||||||
|
|
Loading…
Reference in New Issue