Before reading this article please go through the following articles.
- Introduction to Sencha Touch 2
- Hello World App using Sencha Touch 2
- Sample form application using Sencha Touch 2
- Dealing with containers in Sencha Touch 2
- Working with DataBound Controls
- Introduction to MVC in Sencha Touch 2
- Create your first MVC application using Sencha Touch 2
- Perform CRUD operation using Sencha Touch MVC
Introduction
In the last article, we saw how to perform CRUD operations in Sencha Touch MVC where we performed the CRUD operations using a local-storage proxy. In this article, we will see various types of proxies supported by the Sencha Touch store. Since we have already seen two of them in our previous articles, in this article we will see all the proxies supported by Sencha Touch 2 store with an example. So let's get started.
Types of Proxies
As all of us know, there are two main types of proxies, in other words, Client proxy and Server proxy. Here Sencha Touch supports both of the proxies. These two main proxies again are categorized as below.
Client Proxies
- Local-Storage Proxy
- In-Memory Proxy
Server Proxies
- Ajax Proxy
- JSON-P Proxy
Next, we will go through each of the proxies stated above one by one with example usage.
A. Local-Storage Proxy
A local-storage proxy that we already saw in our last article to perform the CRUD operations using Sencha Touch MVC where we stated that a local-storage proxy uses HTML5 local-storage API. A local-storage proxy cannot save complex data like JSON objects because this is based on key-value pairs hence a local-storage save and retrieve operation automatically serializes and deserializes the data.
The advantage of using a local-storage proxy is that we do not need an internet connection to develop an offline application for mobiles. Have a look at the following snippet to understand local-storage proxies.
- Ext.application({
- launch: function () {//Entry point
- Ext.define('Users', {
- extend: 'Ext.data.Model',
- config: {
- fields: ['Name']
- }
- });
- var store = Ext.create('Ext.data.Store', {
- model: "Users",
- proxy: {
- type: 'localstorage',
- id: 'UserLocalProxy'
- }
- });
- var touchTeam = Ext.create('Ext.List', {
- fullscreen: true,
- store: store,
- itemTpl: '<div>{Name} is member of C-sharp corner.</div>'
- });
- Ext.Viewport.add(touchTeam);
- }
- });
B. In-Memory proxy
An in-memory proxy is nothing but a variable that holds data. If we use in-memory proxies then the data loss occurs on every page refresh. This proxy is defined to use local data globally.
- Ext.application({
- launch: function () {//Entry point
- //define model
- Ext.define('Users', {
- extend: 'Ext.data.Model',
- config: {
- fields: ['Name']
- }
- });
- //define store with memory proxy i.e. inline data
- var store = Ext.create('Ext.data.Store', {
- autoLoad: true,
- model: 'Users',
- data: [{Name:'Krishna Garad'},{Name:'Mahesh Chand'}],
- proxy: {
- type: 'memory'
- }
- });
- var touchTeam = Ext.create('Ext.List', {
- fullscreen: true,
- store: store,
- itemTpl: '<div>{Name} is member of C-sharp corner.</div>'
- });
- Ext.Viewport.add(touchTeam);
- }
- });

Join the conversation! Your thoughts help the community grow.