Webix Storage Interface

Webix library offers its own API for working with application cache and browser local storages: permanent cache, per session cache and cookies.

Accordingly, module contains the following objects:

The objects share three methods:

  • put(name, data, [domain, expires]) - the last two parameters concern only cookie storage. The method allows putting data to browser cache under the stated name. data are passed as JSON object;
  • get(name) - the method derives stored data from local cache for further usage. Data comes in JSON format;
  • remove(name, [domain]) - the last parameter concerns only cookie storage. The method removes data saved under the stated name from local cache.

Working with Local Storage

Local storage can be used for storing any data of an application, e.g. the current state of a component derived with getState() method.

To do this, you put() state object into Webix local storage under a custom name. The data you save should be in the JSON format (which is exactly what getState() returns).

function save_state(){"state", grid.getState());

If the data you'd like to save is a plain JavaScript object, apply Webix serialize() method to it.

To retrieve data from a local storage, use the get() method pointing to the name under which you've saved this or that data.

function restore_state() {
    var state ="state");
    if (state)

Related sample:  DataTable State Object::Session

Working with Cached Data

Although Webix library offers a ready-to-use solution, you can write your own proxy object to enable offline support and set it as the component's url property:

        $proxy: true,   
        load: function(view) {//save data after editing   
            view.attachEvent("onAfterEditStop", function(){
      "app_data", this.serialize());
            view.load("data/data.json", {
                success: function(text){//fresh data, save in cache    
          "app_data", text)
                error: function(){ //probably in offline mode
  • onAfterEditStop event is used to catch data changes and put edited data to cache;
  • cached data are inline data, that's why it is parsed into a component, not loaded.

Making Names of Stores Unique

The module provides the prefix() function to help you avoid possible collisions. It allows you to make the name of the store more unique by upgrading any existing storage (local, session or cookie) with an auto-prefixing functionality.

The method takes two parameters:

  • scope - the id of the store
  • storage - the local storage
mystore ="app_id",;
// putting data into the local cache under the name "app_id_session_key"
mystore.put("session_key", 12)
mystore.get("session_key") // getting data from the local storage  
// -> 12
Back to top