A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://js.devexpress.com/Vue/Documentation/ApiReference/Data_Layer/ODataStore/Methods/ below:

DevExtreme Vue - ODataStore Methods

This section describes the methods that control the ODataStore.

Gets an entity with a specific key.

Parameters:

An entity's key value.

Additional properties.

Object structure:

In the following code, the byKey method loads the product with ID 1 along with the "Category" navigation property:

jQuery
var store = new DevExpress.data.ODataStore({
    // ...
    key: "Product_ID"
});
store.byKey(1, { expand: "Category" })
    .done(function (dataItem) {
        // Process the "dataItem" here
    })
    .fail(function (error) {
        // Handle the "error" here
    });
Angular
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 */ }
        );
    };
}
Vue
<script>
import ODataStore from 'devextreme/data/odata/store';

const store = new ODataStore({
    // ...
    key: 'Product_ID'
});

export default {
    data() {
        return {
            store
        }
    },
    mounted() {
        store.byKey(1, { expand: 'Category' }).then(
            (dataItem) => { /* Process the "dataItem" here */ },
            (error) => { /* Handle the "error" here */ }
        );
    },
    // ...
}
</script>
React
// ...
import ODataStore from 'devextreme/data/odata/store';

const store = new ODataStore({
    // ...
    key: 'Product_ID'
});

class App extends React.Component {
    constructor(props) {
        super(props);
        store.byKey(1, { expand: 'Category' }).then(
            (dataItem) => { /* Process the "dataItem" here */ },
            (error) => { /* Handle the "error" here */ }
        );
    }
}
export default App;

Creates a Query for the OData endpoint.

Parameters:

An object containing the expand, requireTotalCount, and customQueryParams properties.

Object structure:

Name Type Description customQueryParams any

Stores settings that should be sent to the server.

expand

String

|

Array<String>

Specifies the names of navigation properties that the server loads with the ODataStore.

requireTotalCount

Boolean

Specifies whether the resulting data set should contain the total count of data objects.

jQuery
var store = new DevExpress.data.ODataStore({
    // ODataStore is configured here
});
var query = store.createQuery({ expand: "propertyName" });
Angular
import ODataStore from "devextreme/data/odata/store";
// ...
export class AppComponent {
    store: ODataStore;
    constructor() {
        this.store = new ODataStore({
            // ODataStore is configured here
        });
        this.query = this.store.createQuery({ expand: "propertyName" });
    };
}
Vue
<script>
import ODataStore from 'devextreme/data/odata/store';

const store = new ODataStore({
    // ODataStore is configured here
});

export default {
    data() {
        return {
            store
        }
    },
    mounted() {
        this.query = store.createQuery({ expand: 'propertyName' });
    },
    // ...
}
</script>
React
// ...
import ODataStore from 'devextreme/data/odata/store';

const store = new ODataStore({
    // ODataStore is configured here
});

class App extends React.Component {
    constructor(props) {
        super(props);
        this.query = store.createQuery({ expand: 'propertyName' });
    }
}
export default App;
See Also

In the following code, dataObj is a data object added to the database and returned from the server. If the server returns nothing or the store works with local data, dataObj contains the data object passed to the insert method.

jQuery
var store = new DevExpress.data.ODataStore({
    // ODataStore is configured here
});

store.insert({ id: 1, name: "John Doe" })
     .done(function (dataObj, key) {
         // Process the key and data object here
     })
     .fail(function (error) {
         // Handle the "error" here
     });
Angular
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(
                (dataObj) => { /* Process the data object here */ },
                (error) => { /* Handle the "error" here */ }
            );
    };
}
Vue
<script>
import ODataStore from 'devextreme/data/odata_store';

const store = new ODataStore({
    // ODataStore is configured here
});

export default {
    data() {
        return {
            store
        }
    },
    mounted() {
        store.insert({ id: 1, name: "John Doe" })
            .then(
                (dataObj) => { /* Process the data object here */ },
                (error) => { /* Handle the "error" here */ }
            );
    },
    // ...
}
</script>
React
// ...
import ODataStore from 'devextreme/data/odata_store';

const store = new ODataStore({
    // ODataStore is configured here
});

class App extends React.Component {
    constructor(props) {
        super(props);

        store.insert({ id: 1, name: "John Doe" })
            .then(
                (dataObj) => { /* Process the data object here */ },
                (error) => { /* Handle the "error" here */ }
            );
    }
    // ...
}
export default App;

The data item's key value should be unique, otherwise, the insertion will fail.

Gets the key property (or properties) as specified in the key property.

The key property's value.

jQuery
var store = new DevExpress.data.ODataStore({
    // ...
    key: "ProductID"
});

var keyProps = store.key(); // returns "ProductID"
Angular
import ODataStore from "devextreme/data/odata_store";
// ...
export class AppComponent {
    store: ODataStore;
    constructor() {
        this.store = new ODataStore({
            // ...
            key: "ProductID"
        });
        let keyProps = this.store.key(); // returns "ProductID"
    };
}
Vue
<script>
import ODataStore from 'devextreme/data/odata_store';

const store = new ODataStore({
    // ...
    key: 'ProductID'
});

export default {
    data() {
        return {
            store
        }
    },
    mounted() {
        this.keyProps = store.key(); // returns "ProductID"
    },
    // ...
}
</script>
React
// ...
import ODataStore from 'devextreme/data/odata_store';

const store = new ODataStore({
    // ...
    key: 'ProductID'
});

class App extends React.Component {
    constructor(props) {
        super(props);

        this.keyProps = store.key(); // returns "ProductID"
    }
    // ...
}
export default App;

Gets a data item's key value.

The data item's key value.

jQuery
var store = new DevExpress.data.ODataStore({
    // ...
    key: "id"
});

var key = store.keyOf({ id: 1, name: "John Doe" }); // returns 1
Angular
import ODataStore from "devextreme/data/odata_store";
// ...
export class AppComponent {
    store: ODataStore;
    constructor() {
        this.store = new ODataStore({
            // ...
            key: "id"
        });
        let key = this.store.keyOf({ id: 1, name: "John Doe" }); // returns 1
    };
}
Vue
// ...
<script>
import ODataStore from 'devextreme/data/odata_store';

const store = new ODataStore({
    // ...
    key: 'id'
});

export default {
    data() {
        return {
            store
        }
    },
    mounted() {
        this.key = store.keyOf({ id: 1, name: "John Doe" }); // returns 1
    },
    // ...
}
</script>
React
// ...
import ODataStore from 'devextreme/data/odata_store';

const store = new ODataStore({
    // ...
    key: 'id'
});

class App extends React.Component {
    constructor(props) {
        super(props);

        this.keyProps = store.keyOf({ id: 1, name: "John Doe" }); // returns 1
    }
    // ...
}
export default App;

Starts loading data.

Parameters:

Data processing settings.

jQuery
var store = new DevExpress.data.ODataStore({
    // ODataStore is configured here
});

store.load(options)
     .done(function (data) {
         // Process "data" here
     })
     .fail(function (error) {
         // Handle the "error" here
     });
Angular
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 */ }
            );
    };
}
Vue
<script>
import ODataStore from 'devextreme/data/odata_store';

const store = new ODataStore({
    // ODataStore is configured here
});

export default {
    data() {
        return {
            store
        }
    },
    mounted() {
        let options = {
            // Data processing settings are specified here
        };
        store.load(options)
            .then(
                (data) => { /* Process "data" here */ },
                (error) => { /* Handle the "error" here */ }
            );
    },
    // ...
}
</script>
React
// ...
import ODataStore from 'devextreme/data/odata_store';

const store = new ODataStore({
    // ODataStore is configured here
});

class App extends React.Component {
    constructor(props) {
        super(props);

        let options = {
            // Data processing settings are specified here
        };
        store.load(options)
            .then(
                (data) => { /* Process "data" here */ },
                (error) => { /* Handle the "error" here */ }
            );
    }
    // ...
}
export default App;

Detaches all event handlers from a single event.

The object for which this method is called.

Detaches a particular event handler from a single event.

Parameters:

The event's name.

The event's handler.

The object for which this method is called.

Subscribes to an event.

Parameters:

The event's name.

The event's handler.

The object for which this method is called.

Use this method to subscribe to one of the events listed in the Events section.

See Also

Subscribes to events.

Parameters:

Events with their handlers: { "eventName1": handler1, "eventName2": handler2, ...}

The object for which this method is called.

Use this method to subscribe to several events with one method call. Available events are listed in the Events section.

See Also

Pushes data changes to the store and notifies the DataSource.

Parameters:

Data changes to be pushed.

Each data change is an object that can have the following fields:

The following code shows how to use the push(changes) method for each change type:

jQuery
var store = new DevExpress.data.ODataStore({
    // ODataStore is configured here
});

store.push([{ type: "insert", data: dataObj, index: index }]);
store.push([{ type: "update", data: dataObj, key: key }]);
store.push([{ type: "remove", key: key }]);
Angular
import ODataStore from "devextreme/data/odata_store";
// ...
export class AppComponent {
    store: ODataStore;
    constructor() {
        this.store = new ODataStore({
            // ODataStore is configured here
        });
        this.store.push([{ type: "insert", data: dataObj, index: index }]);
        this.store.push([{ type: "update", data: dataObj, key: key }]);
        this.store.push([{ type: "remove", key: key }]);
    };
}
Vue
<script>
import ODataStore from 'devextreme/data/odata_store';

const store = new ODataStore({
    // ODataStore is configured here
});

export default {
    data() {
        return {
            store
        }
    },
    mounted() {
        store.push([{ type: "insert", data: dataObj, index: index }]);
        store.push([{ type: "update", data: dataObj, key: key }]);
        store.push([{ type: "remove", key: key }]);
    }
}
</script>
React
// ...
import ODataStore from 'devextreme/data/odata_store';

const store = new ODataStore({
    // ODataStore is configured here
});

class App extends React.Component {
    constructor(props) {
        super(props);

        store.push([{ type: "insert", data: dataObj, index: index }]);
        store.push([{ type: "update", data: dataObj, key: key }]);
        store.push([{ type: "remove", key: key }]);
    }
    // ...
}
export default App;

DataGrid Real-Time Updates Demo DataGrid SignalR Demo Chart SignalR Demo DataGrid Collaborative Editing Demo

View on GitHub

See Also

Removes a data item with a specific key from the store.

jQuery
// The key consists of a single data field
var singleKeyStore = new DevExpress.data.ODataStore({
    key: "field1",
    // ...
});

// Removes the data item with "field1" being equal to 1
singleKeyStore.remove(1)
    .done(function (key) {
        // Process the "key" here
    })
    .fail(function (error) {
        // Handle the "error" here
    });

// The key consists of several data fields
var compositeKeyStore = new DevExpress.data.ODataStore({
    key: [ "field1", "field2" ],
    // ...
});

// Removes the data item with both "field1" and "field2" being equal to 1
compositeKeyStore.remove({
    field1: 1,
    field2: 1
}).done(function (key) {
    // Process the "key" here
})
.fail(function (error) {
    // Handle the "error" here
});
Angular
import ODataStore from "devextreme/data/odata_store";
// ...
export class AppComponent {
    singleKeyStore: ODataStore;
    compositeKeyStore: ODataStore;

    constructor() {
        // The key consists of a single data field
        this.singleKeyStore = new ODataStore({
            key: "field1",
            // ...
        });
        // Removes the data item with "field1" being equal to 1
        this.singleKeyStore.remove(1)
            .then(
                (key) => { /* Process the "key" here */ },
                (error) => { /* Handle the "error" here */ }
            );

        // The key consists of several data fields
        this.compositeKeyStore = new ODataStore({
            key: [ "field1", "field2" ],
            // ...
        });
        // Removes the data item with both "field1" and "field2" being equal to 1
        this.compositeKeyStore.remove({
            field1: 1,
            field2: 1
        }).then(
            (key) => { /* Process the "key" here */ },
            (error) => { /* Handle the "error" here */ }
        );
    };
}
Vue
<script>
import ODataStore from 'devextreme/data/odata_store';

// The key consists of a single data field
const singleKeyStore = new ODataStore({
    key: "field1",
    // ...
});

// The key consists of several data fields
const compositeKeyStore = new ODataStore({
    key: [ "field1", "field2" ],
    // ...
});

export default {
    data() {
        return {
            singleKeyStore,
            compositeKeyStore
        }
    },
    mounted() {
        // Removes the data item with "field1" being equal to 1
        singleKeyStore.remove(1).then(
            (key) => { /* Process the "key" here */ },
            (error) => { /* Handle the "error" here */ }
        );

        // Removes the data item with both "field1" and "field2" being equal to 1
        compositeKeyStore.remove({
            field1: 1,
            field2: 1
        }).then(
            (key) => { /* Process the "key" here */ },
            (error) => { /* Handle the "error" here */ }
        );
    },
    // ...
}
</script>
React
// ...
import ODataStore from 'devextreme/data/odata_store';

// The key consists of a single data field
const singleKeyStore = new ODataStore({
    key: "field1",
    // ...
});

// The key consists of several data fields
const compositeKeyStore = new ODataStore({
    key: [ "field1", "field2" ],
    // ...
});

class App extends React.Component {
    constructor(props) {
        super(props);

        // Removes the data item with "field1" being equal to 1
        singleKeyStore.remove(1).then(
            (key) => { /* Process the "key" here */ },
            (error) => { /* Handle the "error" here */ }
        );

        // Removes the data item with both "field1" and "field2" being equal to 1
        compositeKeyStore.remove({
            field1: 1,
            field2: 1
        }).then(
            (key) => { /* Process the "key" here */ },
            (error) => { /* Handle the "error" here */ }
        );
    }
    // ...
}
export default App;

Gets the total count of items the load() function returns.

Parameters:

Filtering and grouping properties.

Object structure:

Name Type Description filter

Object

A filtering expression; described in the Filtering section.

group

Object

A grouping expression; described in the Grouping section.

jQuery
var store = new DevExpress.data.ODataStore({
    // ODataStore is configured here
});

store.totalCount()
     .done(function (count) {
         // Process the "count" here
     })
     .fail(function (error) {
         // Handle the "error" here
     });
Angular
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 */ }
            );
    };
}
Vue
<script>
import ODataStore from 'devextreme/data/odata_store';

const store = new ODataStore({
    // ODataStore is configured here
});

export default {
    data() {
        return {
            store
        }
    },
    mounted() {
        store.totalCount()
            .then(
                (count) => { /* Process the "count" here */ },
                (error) => { /* Handle the "error" here */ }
            );
    },
    // ...
}
</script>
React
// ...
import ODataStore from 'devextreme/data/odata_store';

const store = new ODataStore({
    // ODataStore is configured here
});

class App extends React.Component {
    constructor(props) {
        super(props);

        store.totalCount()
            .then(
                (count) => { /* Process the "count" here */ },
                (error) => { /* Handle the "error" here */ }
            );
    }
    // ...
}
export default App;

Updates a data item with a specific key.

Parameters:

A data item's key value.

An object with new values for the data item.

In the following code, dataObj is a data object updated in the database and returned from the server. If the server returns nothing or the store works with local data, dataObj contains the data object passed to the update method.

jQuery
// The key consists of a single data field
var singleKeyStore = new DevExpress.data.ODataStore({
    key: "field1",
    // ...
});

// Updates the data item with "field1" being equal to 1
singleKeyStore.update(1, { name: "John Smith" })
    .done(function (dataObj, key) {
        // Process the key and data object here
    })
    .fail(function (error) {
        // Handle the "error" here
    });

// The key consists of several data fields
var compositeKeyStore = new DevExpress.data.ODataStore({
    key: [ "field1", "field2" ],
    // ...
});

// Updates the data item with both "field1" and "field2" being equal to 1
compositeKeyStore.update(
    { field1: 1, field2: 1 },
    { name: "John Smith" }
).done(function (dataObj, key) {
    // Process the key and data object here
})
.fail(function (error) {
    // Handle the "error" here
});
Angular
import ODataStore from "devextreme/data/odata_store";
// ...
export class AppComponent {
    singleKeyStore: ODataStore;
    compositeKeyStore: ODataStore;

    constructor() {
        // The key consists of a single data field
        this.singleKeyStore = new ODataStore({
            key: "field1",
            // ...
        });
        // Updates the data item with "field1" being equal to 1
        this.singleKeyStore.update(1, { name: "John Smith" })
            .then(
                (dataObj) => { /* Process the data object here */ },
                (error) => { /* Handle the "error" here */ }
            );

        // The key consists of several data fields
        this.compositeKeyStore = new ODataStore({
            key: [ "field1", "field2" ],
            // ...
        });
        // Updates the data item with both "field1" and "field2" being equal to 1
        this.compositeKeyStore.update(
            { field1: 1, field2: 1 },
            { name: "John Smith" }
        ).then(
            (dataObj) => { /* Process the data object here */ },
            (error) => { /* Handle the "error" here */ }
        );
    };
}
Vue
<script>
import ODataStore from 'devextreme/data/odata_store';

// The key consists of a single data field
const singleKeyStore = new ODataStore({
    key: "field1",
    // ...
});

// The key consists of several data fields
const compositeKeyStore = new ODataStore({
    key: [ "field1", "field2" ],
    // ...
});

export default {
    data() {
        return {
            singleKeyStore,
            compositeKeyStore
        }
    },
    mounted() {
        // Updates the data item with "field1" being equal to 1
        singleKeyStore.update(1, { name: "John Smith" }).then(
            (dataObj) => { /* Process the data object here */ },
            (error) => { /* Handle the "error" here */ }
        );

        // Updates the data item with both "field1" and "field2" being equal to 1
        compositeKeyStore.update(
            { field1: 1, field2: 1 },
            { name: "John Smith" }
        ).then(
            (dataObj) => { /* Process the data object here */ },
            (error) => { /* Handle the "error" here */ }
        );
    },
    // ...
}
</script>
React
// ...
import ODataStore from 'devextreme/data/odata_store';

// The key consists of a single data field
const singleKeyStore = new ODataStore({
    key: "field1",
    // ...
});

// The key consists of several data fields
const compositeKeyStore = new ODataStore({
    key: [ "field1", "field2" ],
    // ...
});

class App extends React.Component {
    constructor(props) {
        super(props);

        // Updates the data item with "field1" being equal to 1
        singleKeyStore.update(1, { name: "John Smith" }).then(
            (dataObj) => { /* Process the data object here */ },
            (error) => { /* Handle the "error" here */ }
        );

        // Updates the data item with both "field1" and "field2" being equal to 1
        compositeKeyStore.update(
            { field1: 1, field2: 1 },
            { name: "John Smith" }
        ).then(
            (dataObj) => { /* Process the data object here */ },
            (error) => { /* Handle the "error" here */ }
        );
    }
    // ...
}
export default App;
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!

RetroSearch 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