Cell edit improvements

pull/388/head
cagataycivici 2020-07-04 14:47:11 +03:00
parent 25ec783ce4
commit 9ba8911b6c
4 changed files with 8 additions and 14 deletions

View File

@ -83,12 +83,11 @@ export default {
this.children = this.$children; this.children = this.$children;
}, },
updated() { updated() {
if (this.d_editing) { let query = this.editMode === 'row' ? '[autofocus]' : 'input';
let focusable = DomHandler.findSingle(this.$el, 'input'); let focusable = DomHandler.findSingle(this.$el, query);
if (focusable) { if (focusable && document.activeElement != focusable) {
focusable.focus(); focusable.focus();
} }
}
}, },
methods: { methods: {
resolveFieldData() { resolveFieldData() {

View File

@ -1963,11 +1963,6 @@ export default {
display: none; display: none;
} }
/* Edit */
.p-datatable .p-datatable-tbody > tr > td.p-cell-editing .p-component {
width: 100%;
}
.p-datatable .p-row-editor-init, .p-datatable .p-row-editor-init,
.p-datatable .p-row-editor-save, .p-datatable .p-row-editor-save,
.p-datatable .p-row-editor-cancel { .p-datatable .p-row-editor-cancel {

View File

@ -1116,7 +1116,7 @@ export default {
<Column field="vin" header="Vin"></Column> <Column field="vin" header="Vin"></Column>
<Column field="year" header="Year"> <Column field="year" header="Year">
<template #editor="slotProps"> <template #editor="slotProps">
<InputText v-model="slotProps.data[slotProps.column.field]" /> <InputText v-model="slotProps.data[slotProps.column.field]" autofocus/>
</template> </template>
</Column> </Column>
<Column field="brand" header="Brand"> <Column field="brand" header="Brand">

View File

@ -9,7 +9,7 @@
</div> </div>
</div> </div>
<div class="content-section implementation"> <div class="content-section implementation p-fluid">
<div class="card"> <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>
@ -62,7 +62,7 @@
@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]" /> <InputText v-model="slotProps.data[slotProps.column.field]" autofocus />
</template> </template>
</Column> </Column>
<Column field="name" header="Name"> <Column field="name" header="Name">
@ -149,7 +149,7 @@
@row-edit-init="onRowEditInit" @row-edit-cancel="onRowEditCancel"&gt; @row-edit-init="onRowEditInit" @row-edit-cancel="onRowEditCancel"&gt;
&lt;Column field="code" header="Code"&gt; &lt;Column field="code" header="Code"&gt;
&lt;template #editor="slotProps"&gt; &lt;template #editor="slotProps"&gt;
&lt;InputText v-model="slotProps.data[slotProps.column.field]" /&gt; &lt;InputText v-model="slotProps.data[slotProps.column.field]" autofocus /&gt;
&lt;/template&gt; &lt;/template&gt;
&lt;/Column&gt; &lt;/Column&gt;
&lt;Column field="name" header="Name"&gt; &lt;Column field="name" header="Name"&gt;