使用crud存储代理api中的Extjs变量
Extjs variable in proxy api store using crud
我将在我的代理api存储中放置一个变量(使用crud),但它不起作用。
api配置是一个对象,你能在javascript的对象中使用变量吗?
我使用Sencha Architect和格式api…
你有什么建议吗?
My base store:
Ext.define('ModuleGestion.store.Pays', {
extend: 'Ext.data.Store',
requires: [
'ModuleGestion.model.Pays'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
model: 'ModuleGestion.model.Pays',
storeId: 'StorePays',
proxy: {
type: 'ajax',
api: {
create: 'http://visual04/ModuleGestion/php/Pays.php?action=create',
read: 'http://visual04/ModuleGestion/php/Pays.php?action=read',
update: 'http://visual04/ModuleGestion/php/Pays.php?action=update',
destroy: 'http://visual04/ModuleGestion/php/Pays.php?action=destroy'
},
reader: {
type: 'json',
root: 'data'
},
writer: {
type: 'json',
root: 'data'
}
}
}, cfg)]);
}
});
My model with variable in api proxy
var Url = 'http://visual04/ModuleGestion/php/';
var UrlPays = Url+'Pays.php';
Ext.define('ModuleGestion.store.Pays', {
extend: 'Ext.data.Store',
requires: [
'ModuleGestion.model.Pays'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: true,
model: 'ModuleGestion.model.Pays',
storeId: 'StorePays',
proxy: {
type: 'ajax',
api: '{'r'n create: UrlPays+'action=create','r'n read: UrlPays+'action=read','r'n update: UrlPays+'action=update','r'n destroy: UrlPays+'action=destroy''r'n}',
reader: {
type: 'json',
root: 'data'
},
writer: {
type: 'json',
root: 'data'
}
}
}, cfg)]);
}
});
你可以在文件的任何地方使用UrlPays
,因为你在全局范围内声明了它(即在任何函数之外)。
如果你修改这一行,应该可以工作:
api: '{'r'n create: UrlPays+'action=create','r'n read: UrlPays+'action=read','r'n update: UrlPays+'action=update','r'n destroy: UrlPays+'action=destroy''r'n}',
:
api: {
create: UrlPays + 'action=create',
read: UrlPays + 'action=read',
update: UrlPays + 'action=update',
destroy: UrlPays + 'action=destroy'
},
看到语法高亮的区别了吗?
相关文章:
- 什么's extjs中的mon()和on()之间的区别
- 如何将onChange方法添加到ExtJS 4表单中的所有字段(textField)中
- 如何在Extjs中覆盖lovcombo中的函数
- ExtJS 4中的商店是什么
- 当在EXTJS中的网格中使用时,afterrender不适用于组合框
- 使用 ExtJS 中的函数将元素附加到数组
- 如何从 ExtJs 中的属性文件中读取值
- 使用不同JS文件中的extjs存储
- 网格中的 ExtJS 进度条
- 将本地 JSON 对象加载到网格中的 extjs
- 由于尚未定义 Ext.getBody() 而导致初始页面加载中的 ExtJS 错误
- 使用 JSON 文件中的 extjs 绘制饼图
- 数字字段中的ExtJS 6000分隔符
- 另一个控制器中的ExtJS init控制器
- 需要帮助处理asp.net中的EXTJS
- 项配置中的EXTJS内联initComponent方法
- 使用crud存储代理api中的Extjs变量
- IE9中的ExtJS 5网格过滤和排序中断
- MVC控制器中的ExtJS specialKey事件
- 网格中的EXTJS日期字段未出现/格式化