| id | CustomStore.Options.remove |
|---|---|
| type | function(key) |
Specifies a custom implementation of the remove(key) method.
The key of the data item to be removed.
A Promise that is resolved after the data item is removed.
<!--JavaScript-->
var store = new DevExpress.data.CustomStore({
// ...
remove: function (key) {
return $.ajax({
url: "http://mydomain.com/MyDataService/myEntity/" + encodeURIComponent(key),
method: "DELETE",
})
}
});
<!--TypeScript-->
import { ..., Inject } from "@angular/core";
import CustomStore from "devextreme/data/custom_store";
import { HttpClient, HttpClientModule } from "@angular/common/http";
import { lastValueFrom } from 'rxjs';
// ...
export class AppComponent {
store: CustomStore;
constructor(@Inject(HttpClient) httpClient: HttpClient) {
this.store = new CustomStore({
// ...
remove: (key) => {
return lastValueFrom(httpClient.delete("http://mydomain.com/MyDataService/myEntity/" + encodeURIComponent(key)));
}
});
}
}
@NgModule({
imports: [
// ...
HttpClientModule
],
// ...
})
<!-- tab: App.vue -->
<script>
import CustomStore from 'devextreme/data/custom_store';
import DataSource from 'devextreme/data/data_source';
import 'whatwg-fetch';
function handleErrors(response) {
if (!response.ok) {
throw Error(response.statusText);
}
return response;
}
const store = new CustomStore({
// ...
remove: (key) => {
return fetch(`https://mydomain.com/MyDataService/${encodeURIComponent(key)}`, {
method: "DELETE"
})
.then(handleErrors);
});
export default {
// ...
data() {
return {
store
}
}
}
</script>
<!-- tab: App.js -->
// ...
import CustomStore from 'devextreme/data/custom_store';
import DataSource from 'devextreme/data/data_source';
import 'whatwg-fetch';
function handleErrors(response) {
if (!response.ok)
throw Error(response.statusText);
return response;
}
const store = new CustomStore({
// ...
remove: (key) => {
return fetch(`https://mydomain.com/MyDataService/${encodeURIComponent(key)}`, {
method: "DELETE"
})
.then(handleErrors);
});
});
class App extends React.Component {
// ...
}
export default App;