通过 id-Extjs 将数据加载到模型中
Loading data into model by id-Extjs
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'
})
相关文章:
- 如何将本地json数据加载到Extjs数据模型中
- 有没有比在app.js上绑定模块名称更好的方法来动态加载视图模型和视图以显示模态
- ThreeJS访问加载的obj模型中的对象
- Sails.js:我可以将一些服务/模型打包为npm并在Sails.jss应用程序中加载npm吗
- 如何在three.js中加载指定文件内容而非路径的三维模型
- 如何加载一次模型并将其存储到变量中
- 加载 .dae 模型时不显示纹理
- Webgl 加载 json 模型问题
- 延迟 AngularJS 路由更改,直到加载模型以防止闪烁
- 如何在打开模型时动态加载控制器文件
- 加载模型与三个.js
- 三.js:如何从Web-worker加载动画.json模型
- 如何在角度 2 中向动态加载的子组件提供父组件的模型
- EmberJS:如何在同一条路径上加载多个模型
- 挖空映射:加载数据后,父模型中的计算可观察量不会更新
- AngularJS-关闭tile并从ngRepeat指令AngularJS中的模型加载新视图
- 在Ember.js中渲染应用程序之前,正在等待模型加载
- 使用Ajax从数据库/模型加载数据
- 当我把模型加载到three.js中时,我怎样才能提高性能呢?
- Kendo UI下拉菜单从模型加载数据