2013-07-22 59 views
0

所以我有一個商店無法獲得煎茶店

 
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); 
    } 
}); 

當我試圖打電話給店裏,我得到undefined的第一個元素的元素,但該元素在店裏存在:

 
(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)); 

我回來:

(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' 

這是可以理解爲(5),其數組沒有方法getA t,但是商店沒有任何物品,並且由(4)表示,其中getData元素的數組等於0 ...

在這個時間點與Sencha Touch Framework非常混淆,以及如何獲得元素數組的第一個元素

回答

1

爲什麼不只是使用Ext.data.Store.first() method

我發現當我使用api提供的方法時,我通常是一個更快樂的開發人員。在罕見的情況下,我需要不提供的東西,我會自己導航Sencha對象,但我真的不想嘗試。

讓我知道是否以及爲什麼解決方案可能無法正常工作,我會盡力爲您找到其他的東西。