So I have a store
Ext.define('APN.store.BackupShow', { extend: 'Ext.data.Store', requires: [ 'APN.model.ScheduledShow' ], config: { model: 'APN.model.ScheduledShow', proxy: { type: 'ajax', url: '', reader: { type: 'xml', record: 'item', rootProperty: 'xml' } } }, getShow: function () { if (this.getData().length greater 1) # by some reason stackoverflow didn't allow me to put greater sign in here; return null; // Copy field data across as wrong field is popped. this.getAt(0).set("listimage", this.getAt(0).get("onairimage")); this.getAt(0).set("isbackup", "true"); return this.getAt(0); } });
And when I'm trying to call the first element of the store I get undefined
, however the element exists in the store:
(0) console.log(backupShowStore); (1) console.log(backupShowStore.data); (2) console.log(backupShowStore.getData().all); (3) console.log(backupShowStore.getData().all.length); (4) console.log(backupShowStore.getData().all.getAt(0));
I got back:
(1)
Class _data: Class _model: function () { _modelDefaults: objectClass _proxy: Class _remoteFilter: false _remoteSort: false _storeId: "backupShow" _totalCount: null config: objectClass data: Class _autoFilter: true _autoSort: true _filterRoot: "data" _sortRoot: "data" all: Array[1] 0: Class _data: Object data: Object bufferingProgress: null contentlink: null description: null facebooklink: "http://www.facebook.com/mixmelbourne" id: "ext-record-45" isbackup: null listimage: null onairimage: "http://arntrnassets.mediaspanonline.com/radio/mxm/53808/on-air-default_v3.png" showbody: "Melbourne's widest variety from 2K to today, Mix101.1 with Chrissie & Jane waking up Melbourne weekdays from 6am." showbyline: "The widest variety from 2K to today" showcontentxml: null showemail: null showname: "Mix 101.1" showschedule: null smallimage: null title: null twittername: "mixmelbourne" __proto__: Object id: "ext-record-45" internalId: "ext-record-45" modified: Object phantom: true raw: item stores: Array[1] __proto__: TemplateClass length: 1 __proto__: Array[0]
(2)
_autoFilter: true _autoSort: true _filterRoot: "data" _sortRoot: "data" all: Array[1] config: objectClass dirtyIndices: true getKey: function (record) { indices: Object initConfig: function (){} initialConfig: Object items: Array[1] keys: Array[1] length: 1 map: Object __proto__: TemplateClass
(3)
Array[1] 0: Class length: 1 __proto__: Array[0]
(4)
0
(5)
Uncaught TypeError: Object [object Array] has no method 'getAt'
Which is understandable for (5) as array doesn't have method getAt, however the store doesn't have any items and that is indicated by (4) where the array of getData elements equals to 0...
Am very confused at this point of time with Sencha Touch Framework and how to get the first element of an array of elements