The LocalStore is a store that provides an interface for loading and editing data from HTML Web Storage (also known as window.localStorage) and handling related events.
When configuring the LocalStore, specify the name under which data should be saved in the browser's localStorage object.
jQueryvar states = [ { id: 1, state: "Alabama", capital: "Montgomery" }, { id: 2, state: "Alaska", capital: "Juneau" }, { id: 3, state: "Arizona", capital: "Phoenix" }, // ... ]; var store = new DevExpress.data.LocalStore({ key: "id", data: states, name: "myLocalData", // Other LocalStore properties go here }); // ===== or inside the DataSource ===== var dataSource = new DevExpress.data.DataSource({ store: { type: "local", key: "id", data: states, name: "myLocalData", // Other LocalStore properties go here }, // Other DataSource properties go here });Angular
import LocalStore from "devextreme/data/local_store"; import DataSource from "devextreme/data/data_source"; // ... export class AppComponent { store: LocalStore; dataSource: DataSource; states = [ { id: 1, state: "Alabama", capital: "Montgomery" }, { id: 2, state: "Alaska", capital: "Juneau" }, { id: 3, state: "Arizona", capital: "Phoenix" }, // ... ]; constructor () { this.store = new LocalStore({ key: "id", data: this.states, name: "myLocalData", // Other LocalStore properties go here }); // ===== or inside the DataSource ===== this.dataSource = new DataSource({ store: new LocalStore({ key: "id", data: this.states, name: "myLocalData", // Other LocalStore properties go here }), // Other DataSource properties go here }); } }Vue
<script> import LocalStore from 'devextreme/data/local_store'; import DataSource from 'devextreme/data/data_source'; const states = [ { id: 1, state: 'Alabama', capital: 'Montgomery' }, { id: 2, state: 'Alaska', capital: 'Juneau' }, { id: 3, state: 'Arizona', capital: 'Phoenix' }, // ... ]; const store = new LocalStore({ key: 'id', data: states, name: 'myLocalData', // Other LocalStore properties go here }); // ===== or inside the DataSource ===== const dataSource = new DataSource({ store: new LocalStore({ key: 'id', data: states, name: 'myLocalData', // Other LocalStore properties go here }), // Other DataSource properties go here }); export default { // ... data() { return { store, // ===== or ===== dataSource } } } </script>React
// ... import LocalStore from 'devextreme/data/local_store'; import DataSource from 'devextreme/data/data_source'; const states = [ { id: 1, state: 'Alabama', capital: 'Montgomery' }, { id: 2, state: 'Alaska', capital: 'Juneau' }, { id: 3, state: 'Arizona', capital: 'Phoenix' }, // ... ]; const store = new LocalStore({ key: 'id', data: states, name: 'myLocalData', // Other LocalStore properties go here }); // ===== or inside the DataSource ===== const dataSource = new DataSource({ store: new LocalStore({ key: 'id', data: states, name: 'myLocalData', // Other LocalStore properties go here }), // Other DataSource properties go here }); class App extends React.Component { // ... } export default App;
The
LocalStoreis immutable. You cannot change its configuration at runtime. However, you can use its
methodsto manipulate it.
See AlsoThis section describes properties that configure the LocalStore.
Name Description dataSpecifies the store's associated array.
errorHandlerSpecifies the function that is executed when the store throws an error.
flushIntervalSpecifies a delay in milliseconds between when data changes and the moment these changes are saved in the local storage. Applies only if immediate is false.
immediateSpecifies whether the LocalStore saves changes in the local storage immediately.
keySpecifies the key property (or properties) that provide(s) key values to access data items. Each key value must be unique.
nameSpecifies the name under which data should be saved in the local storage. The dx-data-localStore-
prefix will be added to the name.
A 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.
This section describes methods that control the LocalStore.
This section describes events that the LocalStore raises.
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.
Feel free to share topic-related thoughts here.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