2012-06-13 24 views
2

我嘗試使用直接儲存在ExtJS的
繼承人的代碼,我的店鋪將數據加載到模型由ID-ExtJS的

Ext.define('IDE.store.Files', { 
    extend: 'Ext.data.Store', 
    proxy: { 
     type: 'direct', 
     api: { 
      create:Files.AddNew, 
      read:Files.GetFile, 
      update:Files.Update, 
      destroy:Files.Delete, 
      //load:Files.GetFile 
     }, 
     paramOrder:'Path' 
    }, 
    model:'IDE.model.File' 
}) 

爲模型的代碼是

Ext.define('IDE.model.File', { 
    extend: 'Ext.data.Model', 
    fields: [ 
     { name: 'Path', type: 'string' }, 
     { name: 'Name', type: 'string' }, 
     { name: 'Extention', type: 'string' }, 
     { name: 'Content', type: 'string' } 
    ], 
    idProperty:'Path', 
    store:'IDE.store.Files' 
}) 

,你可以看到idPropertyPath
以下代碼段給出錯誤

//this.getStore('IDE.store.Files').load(path, { sucess: function (file) { 
//    console.log(file.get('Content'));   
//   } }); 
this.getStore('IDE.store.Files').load(path); 

這裏即時得到來自什麼地方,並試圖path從特定路徑加載一個文件 誤差

Ext.data.proxy.Direct.doRequest(): No direct function specified for this proxy 

現在的問題是ExtJS的的不是足夠的單據和無處不在我搜索我只能看到在proxyapi對象中的4 api。 哪些
1.創建
2.read
3.update
4.destroy

我失去了其API? OR
我在哪裏需要給一個直接的功能load()

+0

究竟是否使用的是ExtJS的版本?因爲你給load()的參數看起來不正確。另外,可以從api中刪除load:config: - 不支持。 – Izhaki

+0

ooops那是因爲我在嘗試一些東西..現在我編輯了這個問題來反映確切的情況 –

+0

EXT上的哪個版本? 4.0.7? 4.1? – Izhaki

回答

1

有,我可以找出我的代碼,所以只是把這裏社區的幫助多個問題。
1.我打電話負載的功能的方式是正確的..它只是行的事發生了參數,但與範圍和回調使MAYB那是錯誤說 http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store-method-load
2.如果我只是刪除api整個對象..和使用directFn配置選項,然後它似乎工作..

代碼:

Ext.define('IDE.store.Files', { 
    extend: 'Ext.data.Store', 
    proxy: { 
     type: 'direct', 
     directFn: Files.GetFile, // <--- new line of code 
     api: { 
      create:Files.AddNew, 
      //read:Files.GetFile, // <--- old line of code 
      update:Files.Update, 
      destroy:Files.Delete 
     }, 
     paramOrder:'Path' 
    }, 
    model:'IDE.model.File' 
}) 
+1

我添加了代碼,以便下一位讀者可以看到代碼的樣子。 – MacGyver