-
25 Oct 2012 10:26 PM #1
what's the type of 'records' in callback(records,option,success) in json store.load
what's the type of 'records' in callback(records,option,success) in json store.load
Hi all,i tried to use the data(records) returned from the server,but dont know what type of the data is,my code is like below .seems it's an array,but i just cant use the its elements.
data from serverCode:xxx.store.load(//json store { callback: function(records, options, success){ this.reader.jsonData.groups.group1;//i can call it like this records.groups;//doesnt work records[0];//[object Object] records[0].group1;//undefined records.length==6// } });
Code:{ "groups" : { "group1" : "Week33", "group2" : "Week34", "group3" : "Week35", "group4" : "Week36", }, "rows": [ { "data1":"data" } ], "success" : true, "metaData" : null, "cacheName" : "", "totalRowCount" : 6 }
-
25 Oct 2012 11:16 PM #2
Hi,
you can see this link :1. http://docs.sencha.com/ext-js/3-4/#!/api/Ext.data.Store-event-load
2.http://docs.sencha.com/ext-js/3-4/#!...re-method-loadsword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
28 Oct 2012 5:14 PM #3
Hi Sword,do you know why i get the error ' records.get is not a function ' when i try to use the function that belongs to Ext.data.Record?
-
29 Oct 2012 10:08 PM #4
Hi,
you can try this:
Code:for(var i=0; i< records.length;i++){ records[i].get('propertyname'); }sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
29 Oct 2012 10:35 PM #5
Hi Sword,the function 'get' works now according to what u said.but still cant get the data.
like
Code:records[0].get('groups') ;//undefined
-
29 Oct 2012 11:25 PM #6
Hi,
you can use like this one:
Code:records[0].get('group1')sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.
-
30 Oct 2012 12:00 AM #7
Hi,I finally get the data like below
record[0].get('data1')
let me show you my store code
Code:var WorkOrderRecord = Ext.data.Record.create([ {name: 'data1'} ]); myStore = Ext.extend(Ext.ux.MultiGroupingStore, { constructor: function(cfg) { cfg = cfg || {}; myStore.superclass.constructor.call(this, Ext.apply({ proxy: new Ext.data.HttpProxy({ method: 'POST', url: '**/test.json' }), autoLoad: false, reader: new Ext.data.JsonReader({ root: 'rows', successProperty: 'success', messageProperty: 'message', totalProperty: 'total', }, WorkOrderRecord ) })); } });
-
30 Oct 2012 1:17 AM #8
Providing your root config in the beginning would've helped

I really would recommend using Firebug and the console.log() function, since this would've helped you to see exactly what type of object records was, and what the child names are.
-
30 Oct 2012 2:49 AM #9
Hey buddy,how to use firebug to see the child names of records?
-
30 Oct 2012 3:03 AM #10



Reply With Quote