BsArrayStore
A built-in data store class for working with collection of entity objects locally.
Overview
Vue MDBootstrap provides built-in data store class for working with collection of entity objects locally. BsArrayStore is used to store collection of entity objects locally and your application is reponsible to manage them. Components like BsCombobox and BsListbox are examples of components that use BsStore for their data binding.
Usage Example
ts
import { BsArrayStore } from "vue-mdbootstrap";
const myStore = new BsArrayStore(
[
{id: 1, name: 'Sandra Adams'},
{id: 2, name: 'Ali Connors'},
{id: 3, name: 'Trevor Hansen'},
{id: 4, name: 'Tucker Smith'},
{id: 5, name: 'Britta Holt'},
{id: 6, name: 'Jane Smith'},
{id: 7, name: 'John Smith'},
{id: 8, name: 'Sandra Williams'}
], {
idProperty: 'id'
}
);
Filtering Data
BsArrayStore provides functionality to filter dataset on demands. See example below:
ts
import { BsArrayStore } from "vue-mdbootstrap";
const myStore = new BsArrayStore(
[{...}, {...}, {...}],
{ idProperty: 'id' }
);
// apply filter to the dataset
myStore.filters = [{ property: 'name', value: 'john', operator: 'startwith' }];
// do something
console.info('datas: ', myStore.dataItems);
Sorting Data
BsArrayStore provides functionality to sort dataset on demands. See example below:
ts
import { BsArrayStore } from "vue-mdbootstrap";
const myStore = new BsArrayStore(
[{...}, {...}, {...}],
{ idProperty: 'id' }
);
// sorts by a single field
const results = myStore.sort('name', 'asc');
// sorts by multiple fields
const results = myStore.sort([
{property: 'age', direction: 'desc'},
{property: 'name', direction: 'asc'}
]);