Offline apps

Problem

How to create offline apps with DHTMLX Touch ?

Solution

DHTMLX Touch offers an easy way to create offline apps (the online apps which continue to work even when a network is unavailable).

Generally, to make an app work in offline mode you should use the dhx.proxy component. The component allows you to send web requests via HTTP proxy and store the latest successful data files and unsuccessful web requests locally.

  1. So first of all, initialize dhx.proxy.

    var source = new dhx.proxy({
    	  url: "./data.php",
    	  storage: dhx.storage.cookie
    });
  2. Once you have initialized dhx.proxy, set the url parameter of the component(s) that will take data from the server to its instance.

    dhx.ui({
              view:"list", 
              id:"mylist", 
              url: source,
              ...
    })
  3. If you use dataProcessor, set its url parameter to the dhx.proxy instance as well.

    var dp = new dhx.DataProcessor({
    	  master:$$('mylist'),
    	  url: source
    });
  4. If you don't use dataProcessor but specify the client-server logic manually you can use the get() and post() methods of dhx.proxy (the methods work like normal Ajax GET and POST requests).

    var params = ["a=1", "b=2"]; // request parameters list
     
    source.post(params.join('&'), {
    	              success: function() {
    		         ...
    	              },
    	              error: function() {
    		         ...
    	              }
    });

Related sample: 10_server/02_saving/08_dataprocessor_proxy_offine.html