通过 id-Extjs 将数据加载到模型中

Loading data into model by id-Extjs

本文关键字:模型 加载 数据 id-Extjs 通过      更新时间:2023-09-26

im 尝试在 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 的文档还不够,我搜索的任何地方我只能在 proxy api对象中看到 4 个 API。哪些是
1.创建
2.阅读
3.更新
4.销毁

我缺少哪个 API?或
我需要在哪里为load()提供直接函数

我可以用我的代码解决多个问题,所以只是放在这里寻求社区的帮助。
1. 我调用加载函数的方式是正确的。它只是不接受参数,而是带有作用域和回调的整个对象,所以 mayb 这是错误说的
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store-method-load2.如果我只是删除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'
})