2

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

ご覧のidPropertyとおりPath
、次のコードセグメントでエラーが発生しています

//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 のドキュメントが十分ではなく、どこを検索しても のapiオブジェクトに 4 つの API しか表示されないことですproxy
1.create
2.read
3.update
4.destroy のうち、不足している API はどれ

ですか? または
、どこに直接関数を与える必要がありますかload()

4

1 に答える 1

1

私のコードで理解できる問題が複数あるので、コミュニティの助けを借りてここに置いてください。
1. ロード関数を呼び出す方法は正しい..そして、それは単にパラメータを取りますが、スコープとコールバックを持つオブジェクト全体を取るので、 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'
})
于 2012-06-18T07:25:59.963 に答える