Borrow old data before save on instansi
This commit is contained in:
@ -8,6 +8,8 @@
|
|||||||
<DxDataGrid ref="currDataGrid"
|
<DxDataGrid ref="currDataGrid"
|
||||||
:data-source="customDataSource"
|
:data-source="customDataSource"
|
||||||
key-expr="id"
|
key-expr="id"
|
||||||
|
@editing-start="onEditingStart"
|
||||||
|
@saving="onSaving"
|
||||||
:allow-column-reordering="true"
|
:allow-column-reordering="true"
|
||||||
:column-auto-width="true">
|
:column-auto-width="true">
|
||||||
<DxRemoteOperations :group-paging="true" />
|
<DxRemoteOperations :group-paging="true" />
|
||||||
@ -157,8 +159,43 @@ export default {
|
|||||||
return {
|
return {
|
||||||
//jsonUrl: URL,
|
//jsonUrl: URL,
|
||||||
customDataSource,
|
customDataSource,
|
||||||
|
rowEdit: {
|
||||||
|
id: null,
|
||||||
|
alamat: '',
|
||||||
|
instansi: '',
|
||||||
|
isDelete: false,
|
||||||
|
keterangan: ''
|
||||||
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
|
||||||
|
onEditingStart(e) {
|
||||||
|
this.rowEdit = e.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
async onSaving(e) {
|
||||||
|
const isCanceled = new Promise((resolve) => {
|
||||||
|
|
||||||
|
const data = Object.assign(this.rowEdit, e.changes[0].data);
|
||||||
|
|
||||||
|
fetch(`${URL}/${data.id}`, {
|
||||||
|
method: 'PUT',
|
||||||
|
body: JSON.stringify(data),
|
||||||
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(() => resolve(false));
|
||||||
|
|
||||||
|
resolve(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
e.cancel = isCanceled;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user