-
31 Jul 2012 1:10 PM #1
Answered: How can I get data?
Answered: How can I get data?
How can I get data a,b,c from Ext.data.Store ?PHP Code:{
"a":7,
"b":26,
"c":40,
"records":[
{"aa":"1","bb":"2"}
]
}
-
Best Answer Posted by scottmartin
The server JSON should return these values in the result set and you simply need to set these values in your reader and it will be used.
Scott.Code:reader : { type : 'json', totalProperty : 'total', successProperty : 'success', messageProperty : 'message', root : 'items' },
-
31 Jul 2012 1:31 PM #2Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,185
- Vote Rating
- 194
- Answers
- 433
Is the data already in the store? Where do you want it? in a form?
Scott.
-
31 Jul 2012 2:04 PM #3
in constructing the grid, I get the data, but can not apply to them
-
31 Jul 2012 2:31 PM #4Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,185
- Vote Rating
- 194
- Answers
- 433
Here is a basic example:
Code:{ 'items': [ { 'name': 'Lisa', 'email': 'lisa@simpsons.com', 'change': 100 }, { 'name': 'Bart', 'email': 'bart@simpsons.com', 'change': -20 }, { 'name': 'Homer', 'email': 'home@simpsons.com', 'change': 23 }, { 'name': 'Marge', 'email': 'marge@simpsons.com', 'change': -11 } ] }Code:Ext.onReady(function(){ Ext.create('Ext.data.Store', { storeId:'simpsonsStore', fields:['name', 'email', 'change',], autoLoad: true, proxy: { type: 'ajax', url: 'data.json', reader: { type: 'json', root: 'items' } } }); Ext.create('Ext.grid.Panel', { title: 'Simpsons', store: Ext.data.StoreManager.lookup('simpsonsStore'), columns: [ { header: 'Name', dataIndex: 'name' }, { header: 'Email', dataIndex: 'email', flex: 1 }, { header: 'Change', dataIndex: 'change' } ], height: 200, width: 400, renderTo: Ext.getBody() }); });
-
31 Jul 2012 2:42 PM #5
need these data to obtain: (total,closed,itc BEFORE items)
these data are easily transferred from the server after the recount than on the clientPHP Code:{
'total':200,
'closed':300,
'itc':'zzz...'
'items': [
{
'name': 'Lisa',
'email': 'lisa@simpsons.com',
'change': 100
},
{
'name': 'Bart',
'email': 'bart@simpsons.com',
'change': -20
},
{
'name': 'Homer',
'email': 'home@simpsons.com',
'change': 23
},
{
'name': 'Marge',
'email': 'marge@simpsons.com',
'change': -11
}
]
}
sampl:
1.png
in order not to perform this function:
PHP Code:var size = 0; var foldersCount = 0; var filesCount = 0;
this.store.each(function(record) {
if(record.get('filesize') !== '-'){
size = Number(size + record.get('filesize'));
filesCount++;
}
else {foldersCount++;}
});
-
31 Jul 2012 8:02 PM #6Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,185
- Vote Rating
- 194
- Answers
- 433
Are you referring to the totalProperty, etc?
Scott.
-
1 Aug 2012 12:13 AM #7
yes yes yes

and any other data, not only totalProperty.
-
1 Aug 2012 7:00 AM #8Sencha - Support Team
- Join Date
- Jul 2010
- Location
- Houston, Tx
- Posts
- 7,185
- Vote Rating
- 194
- Answers
- 433
The server JSON should return these values in the result set and you simply need to set these values in your reader and it will be used.
Scott.Code:reader : { type : 'json', totalProperty : 'total', successProperty : 'success', messageProperty : 'message', root : 'items' },
-
1 Aug 2012 2:25 PM #9


Reply With Quote