DevExtreme Angular - ODataStore Methods
byKey(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.
- import ODataStore from "devextreme/data/odata_store";
- // ...
- export class AppComponent {
- store: ODataStore;
- constructor() {
- this.store = new ODataStore({
- // ODataStore 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 */ }
- );
- };
- }
byKey(key, extraOptions)
A Promise that is resolved after the entity is loaded. It is a native Promise or a jQuery.Promise when you use jQuery.
In the following code, the byKey method loads the product with ID 1
along with the "Category"
navigation property:
- import ODataStore from "devextreme/data/odata/store";
- // ...
- export class AppComponent {
- store: ODataStore;
- constructor() {
- this.store = new ODataStore({
- // ...
- key: "Product_ID"
- });
- this.store.byKey(1, { expand: "Category" }).then(
- (dataItem) => { /* Process the "dataItem" here */ },
- (error) => { /* Handle the "error" here */ }
- );
- };
- }
createQuery(loadOptions)
An object containing the expand, requireTotalCount, and customQueryParams properties.
- import ODataStore from "devextreme/data/odata/store";
- // ...
- export class AppComponent {
- store: ODataStore;
- constructor() {
- this.store = new ODataStore({
- // ODataStore is configured here
- });
- this.store.createQuery({ expand: "propertyName" });
- };
- }
See Also
insert(values)
A Promise that is resolved after the data item is added. It is a native Promise or a jQuery.Promise when you use jQuery.
- import ODataStore from "devextreme/data/odata_store";
- // ...
- export class AppComponent {
- store: ODataStore;
- constructor() {
- this.store = new ODataStore({
- // ODataStore is configured here
- });
- this.store.insert({ id: 1, name: "John Doe" })
- .then(
- (dataItem) => { /* Process the "dataItem" here */ },
- (error) => { /* Handle the "error" here */ }
- );
- };
- }
load()
A Promise that is resolved after data is loaded. It is a native Promise or a jQuery.Promise when you use jQuery.
load(options)
A Promise that is resolved after data is loaded. It is a native Promise or a jQuery.Promise when you use jQuery.
- import ODataStore from "devextreme/data/odata_store";
- import DevExpress from "devextreme/bundles/dx.all";
- // ...
- export class AppComponent {
- store: ODataStore;
- constructor() {
- this.store = new ODataStore({
- // ODataStore 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 */ }
- );
- };
- }
remove(key)
A Promise that is resolved after the data item is removed. It is a native Promise or a jQuery.Promise when you use jQuery.
- import ODataStore from "devextreme/data/odata_store";
- // ...
- export class AppComponent {
- store: ODataStore;
- constructor() {
- this.store = new ODataStore({
- // ODataStore 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.
- import ODataStore from "devextreme/data/odata_store";
- // ...
- export class AppComponent {
- store: ODataStore;
- constructor() {
- this.store = new ODataStore({
- // ODataStore is configured here
- });
- this.store.totalCount()
- .then(
- (count) => { /* Process the "count" here */ },
- (error) => { /* Handle the "error" here */ }
- );
- };
- }
update(key, values)
A Promise that is resolved after the data item is updated. It is a native Promise or a jQuery.Promise when you use jQuery.
- import ODataStore from "devextreme/data/odata_store";
- // ...
- export class AppComponent {
- store: ODataStore;
- constructor() {
- this.store = new ODataStore({
- // ODataStore 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.