The CustomStore enables you to implement custom data access logic for consuming data from any source.
DevExtreme provides extensions for ASP.NET and PHP that configure the CustomStore and implement server-side data processing. A third-party extension is available for MongoDB. You can also implement the CustomStore manually.
The CustomStore's implementation depends on whether data is processed on the client or server. For client-side data processing, implement the load function to load data from the data source. Refer to the Load Data in the Raw Mode article for more information.
For server-side data processing, implement the load function to send data processing parameters to the server. The server should send back processed data. load and CustomStore have specifics that depend on the UI component that uses the CustomStore. Refer to the load description for more information.
If your data source supports CRUD operations, implement the insert, update, and remove functions.
The following code example uses CustomStore to specify CRUD operations for a component. For a more in-depth example, refer to the following article: Custom Data Sources.
jQueryconst store = new DevExpress.data.CustomStore({ key: "id", load: function (loadOptions) { // ... }, insert: function (values) { // ... }, update: function (key, values) { // ... }, remove: function (key) { // ... } }); // ===== or inside the DataSource ===== const dataSource = new DevExpress.data.DataSource({ // ... // a mix of CustomStore and DataSource properties // ... });Angular
import CustomStore from "devextreme/data/custom_store"; import DataSource from "devextreme/data/data_source"; // ... export class AppComponent { store: CustomStore; dataSource: DataSource; constructor () { this.store = new CustomStore({ key: "id", load: (loadOptions) => { // ... }, insert: (values) => { // ... }, update: (key, values) => { // ... }, remove: (key) => { // ... } }); // ===== or inside the DataSource ===== this.dataSource = new DataSource({ // ... // a mix of CustomStore and DataSource properties // ... }); } }Vue
<script> import CustomStore from 'devextreme/data/custom_store'; import DataSource from 'devextreme/data/data_source'; const store = new CustomStore({ key: 'id', load: (loadOptions) => { // ... }, insert: (values) => { // ... }, update: (key, values) => { // ... }, remove: (key) => { // ... } }); // ===== or inside the DataSource ===== const dataSource = new DataSource({ // ... // a mix of CustomStore and DataSource properties // ... }); export default { // ... data() { return { store, // ===== or ===== dataSource } } } </script>React
// ... import CustomStore from 'devextreme/data/custom_store'; import DataSource from 'devextreme/data/data_source'; const store = new CustomStore({ key: 'id', load: (loadOptions) => { // ... }, insert: (values) => { // ... }, update: (key, values) => { // ... }, remove: (key) => { // ... } }); // ===== or inside the DataSource ===== const dataSource = new DataSource({ // ... // a mix of CustomStore and DataSource properties // ... }); function App() { // ... } export default App;
The
CustomStoreis immutable. You cannot change its configuration at runtime. However, you can use its
methodsto manipulate it.
See AlsoThis section describes properties that configure the CustomStore.
Name Description byKeySpecifies a custom implementation of the byKey(key) method.
cacheRawDataSpecifies whether raw data should be saved in the cache. Applies only if loadMode is "raw".
errorHandlerSpecifies the function that is executed when the store throws an error.
insertSpecifies a custom implementation of the insert(values) method.
keySpecifies the key property (or properties) that provide(s) key values to access data items. Each key value must be unique.
loadSpecifies a custom implementation of the load(options) method.
loadModeSpecifies how data returned by the load function is treated.
onInsertedA function that is executed after a data item is added to the store.
onInsertingA function that is executed before a data item is added to the store.
onLoadedA function that is executed after data is loaded to the store.
onLoadingA function that is executed before data is loaded to the store.
onModifiedA function that is executed after a data item is added, updated, or removed from the store.
onModifyingA function that is executed before a data item is added, updated, or removed from the store.
onPushThe function executed before changes are pushed to the store.
onRemovedA function that is executed after a data item is removed from the store.
onRemovingA function that is executed before a data item is removed from the store.
onUpdatedA function that is executed after a data item is updated in the store.
onUpdatingA function that is executed before a data item is updated in the store.
removeSpecifies a custom implementation of the remove(key) method.
totalCountSpecifies a custom implementation of the totalCount(options) method.
updateSpecifies a custom implementation of the update(key, values) method.
useDefaultSearchSpecifies whether the store combines the search and filter expressions. Defaults to true if the loadMode is "raw" and false if it is "processed".
This section describes the methods used to access data associated with the CustomStore.
Name Description insertedRaised after a data item is added to the store.
insertingRaised before a data item is added to the store.
loadedRaised after data is loaded to the store.
loadingRaised before data is loaded to the store.
modifiedRaised after a data item is added, updated, or removed from the store.
modifyingRaised before a data item is added, updated, or removed from the store.
pushRaised before changes are pushed to the store.
removedRaised after a data item is removed from the store.
removingRaised before a data item is removed from the store.
updatedRaised after a data item is updated in the store.
updatingRaised before a data item is updated in the store.
This section describes the loadOptions object's fields.
import { Load_Options } from "devextreme/
common/data"
This object is used to specify settings according to which the server should process data. More often these settings are passed as a parameter to the load function and depend on the operations (paging, filtering, sorting, etc.) that you have enabled in the DataSource or UI component.
See AlsoRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4