DevExtreme Angular - CustomStore Methods
This section describes the methods used to access data associated with the CustomStore.
byKey(key)
Gets a data item with a specific key.
A Promise that is resolved after the data item is loaded. It is a native Promise or a jQuery.Promise when you use jQuery.
jQuery
var store = new DevExpress.data.CustomStore({
    // CustomStore is configured here
});
// Getting the data item with key 1
store.byKey(1)
    .done(function (dataItem) {
        // Process the "dataItem" here
    })
    .fail(function (error) {
        // Handle the "error" here
    });Angular
import CustomStore from "devextreme/data/custom_store";
// ...
export class AppComponent {
    store: CustomStore;
    constructor() {
        this.store = new CustomStore({
            // CustomStore is configured here
        });
        // Getting the data item with key 1
        this.store.byKey(1).then(
            (dataItem) => { /* Process the "dataItem" here */ },
            (error) => { /* Handle the "error" here */ }
        );
    };
}clearRawDataCache()
Deletes data from the cache. Takes effect only if the cacheRawData option is true.
jQuery
var store = new DevExpress.data.CustomStore({
    // CustomStore is configured here
    cacheRawData: true
});
store.clearRawDataCache();Angular
import CustomStore from "devextreme/data/custom_store";
// ...
export class AppComponent {
    store: CustomStore;
    constructor( ... ) {
        this.store = new CustomStore({
            // CustomStore is configured here
            cacheRawData: true
        });
        this.store.clearRawDataCache();
    };
}insert(values)
Adds a data item to the store.
A data item.
A Promise that is resolved after the data item is added. It is a native Promise or a jQuery.Promise when you use jQuery.
jQuery
var store = new DevExpress.data.CustomStore({
    // CustomStore is configured here
});
store.insert({ id: 1, name: "John Doe" })
     .done(function (dataItem, key) {
         // Process the "key" and "dataItem" here
     })
     .fail(function (error) {
         // Handle the "error" here
     });Angular
import CustomStore from "devextreme/data/custom_store";
// ...
export class AppComponent {
    store: CustomStore;
    constructor() {
        this.store = new CustomStore({
            // CustomStore is configured here
        });
        this.store.insert({ id: 1, name: "John Doe" })
            .then(
                (dataItem) => { /* Process the "dataItem" here */ },
                (error) => { /* Handle the "error" here */ }
            );
    };
}key()
Gets the key property (or properties) as specified in the key option.
The key option's value.
jQuery
var store = new DevExpress.data.CustomStore({
    // ...
    key: "ProductID"
});
var keyProps = store.key(); // returns "ProductID"Angular
import CustomStore from "devextreme/data/custom_store";
// ...
export class AppComponent {
    store: CustomStore;
    constructor() {
        this.store = new CustomStore({
            // ...
            key: "ProductID"
        });
        let keyProps = this.store.key(); // returns "ProductID"
    };
}keyOf(obj)
Gets a data item's key value.
A data item.
The data item's key value.
jQuery
var store = new DevExpress.data.CustomStore({
    // ...
    key: "id"
});
var key = store.keyOf({ id: 1, name: "John Doe" }); // returns 1Angular
import CustomStore from "devextreme/data/custom_store";
// ...
export class AppComponent {
    store: CustomStore;
    constructor() {
        this.store = new CustomStore({
            // ...
            key: "id"
        });
        let key = this.store.keyOf({ id: 1, name: "John Doe" }); // returns 1
    };
}load()
Starts loading data.
A Promise that is resolved after data is loaded. It is a native Promise or a jQuery.Promise when you use jQuery.
load(options)
Starts loading data.
Data processing settings.
A Promise that is resolved after data is loaded. It is a native Promise or a jQuery.Promise when you use jQuery.
jQuery
var store = new DevExpress.data.CustomStore({
    // CustomStore is configured here
});
store.load(options)
     .done(function (data) {
         // Process "data" here
     })
     .fail(function (error) {
         // Handle the "error" here
     });Angular
import CustomStore from "devextreme/data/custom_store";
import DevExpress from "devextreme/bundles/dx.all";
// ...
export class AppComponent {
    store: CustomStore;
    constructor() {
        this.store = new CustomStore({
            // CustomStore is configured here
        });
        let options: DevExpress.data.LoadOptions = {
            // Data processing settings are specified here
        };
        this.store.load(options)
            .then(
                (data) => { /* Process "data" here */ },
                (error) => { /* Handle the "error" here */ }
            );
    };
}off(eventName)
Detaches all event handlers from a single event.
The event's name.
The object for which this method is called.
See Also
- Handle Events: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
off(eventName, eventHandler)
Detaches a particular event handler from a single event.
The object for which this method is called.
See Also
- Handle Events: jQuery | Angular | AngularJS | Knockout | ASP.NET MVC
on(eventName, eventHandler)
Subscribes to an event.
The object for which this method is called.
on(events)
Subscribes to events.
Events with their handlers: { "eventName1": handler1, "eventName2": handler2, ...}
The object for which this method is called.
remove(key)
Removes a data item with a specific key from the store.
A Promise that is resolved after the data item is removed. It is a native Promise or a jQuery.Promise when you use jQuery.
jQuery
var store = new DevExpress.data.CustomStore({
    // CustomStore is configured here
});
// Removing the data item with key 1
store.remove(1)
     .done(function (key) {
         // Process the "key" here
     })
     .fail(function (error) {
         // Handle the "error" here
     });Angular
import CustomStore from "devextreme/data/custom_store";
// ...
export class AppComponent {
    store: CustomStore;
    constructor() {
        this.store = new CustomStore({
            // CustomStore is configured here
        });
        // Removing the data item with key 1
        this.store.remove(1)
            .then(
                (key) => { /* Process the "key" here */ },
                (error) => { /* Handle the "error" here */ }
            );
    };
}totalCount(options)
Gets the total count of items the load() function returns.
A Promise that is resolved after the total item count is obtained. It is a native Promise or a jQuery.Promise when you use jQuery.
jQuery
var store = new DevExpress.data.CustomStore({
    // CustomStore is configured here
});
store.totalCount()
     .done(function (count) {
         // Process the "count" here
     })
     .fail(function (error) {
         // Handle the "error" here
     });Angular
import CustomStore from "devextreme/data/custom_store";
// ...
export class AppComponent {
    store: CustomStore;
    constructor() {
        this.store = new CustomStore({
            // CustomStore is configured here
        });
        this.store.totalCount()
            .then(
                (count) => { /* Process the "count" here */ },
                (error) => { /* Handle the "error" here */ }
            );
    };
}update(key, values)
Updates a data item with a specific key.
A Promise that is resolved after the data item is updated. It is a native Promise or a jQuery.Promise when you use jQuery.
jQuery
var store = new DevExpress.data.CustomStore({
    // CustomStore is configured here
});
store.update(1, { name: "John Smith" })
     .done(function (key, dataItem) {
         // Process the "key" and "dataItem" here
     })
     .fail(function (error) {
         // Handle the "error" here
     });Angular
import CustomStore from "devextreme/data/custom_store";
// ...
export class AppComponent {
    store: CustomStore;
    constructor() {
        this.store = new CustomStore({
            // CustomStore is configured here
        });
        this.store.update(1, { name: "John Smith" })
            .then(
                (key) => { /* Process the "key" here */ },
                (error) => { /* Handle the "error" here */ }
            );
    };
}If you have technical questions, please create a support ticket in the DevExpress Support Center.