PDA

View Full Version : proxy in extjs



lucius_malfoy
12 Feb 2013, 4:51 AM
hello

in this code



Ext.create('Ext.data.Store', { storeId:'simpsonsStore',
fields:['name', 'email', 'phone', 'city'],
data:{'items':[
{ 'name': 'Lisa', "email":"lisa@simpsons.com", "phone":"555-111-1224", "city":"tbilisi" },
{ 'name': 'Bart', "email":"bart@simpsons.com", "phone":"555-222-1234" },
{ 'name': 'Homer', "email":"home@simpsons.com", "phone":"555-222-1244" },
{ 'name': 'Marge', "email":"marge@simpsons.com", "phone":"555-222-1254" }
]},
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'items'
}
}
});


Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' },
{text: 'city', dataIndex: 'city'}
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});

what is doing this part?


proxy: { type: 'memory',
reader: {
type: 'json',
root: 'items'
}

droessner
12 Feb 2013, 8:39 AM
It tells the store that the store data should be loaded from memory. The store data in this case is a JSON object with root "items". The proxy defines where/how to load that data into the store.