当我定义一个模型“TeMdl”然后使用 Fn TeMdl.load(1) 时,它将发送一个参数 id=1 的请求。所以..如何更改 id 参数以便请求可以像这样:“......\?uid=1”?我是 extjs 的新手!
问问题
1912 次
1 回答
1
来自 Ext 文档中的评论:
load() 方法将不遵守模型的 idProperty,并假定它是“id”。
以下子类通过使用 idProperty 而不是 id 来修复此行为。
Ext.define("Ux.data.Model", {
extend: "Ext.data.Model",
statics: {
load: function(id, config){
config = Ext.apply({}, config);
var params={};
params[this.prototype.idProperty] = id;
config = Ext.applyIf(config, {
action: 'read',
params: params
});
var operation = Ext.create('Ext.data.Operation', config),
scope = config.scope || this,
record = null,
callback;
callback = function(operation) {
if (operation.wasSuccessful()) {
record = operation.getRecords()[0];
Ext.callback(config.success, scope, [record, operation]);
} else {
Ext.callback(config.failure, scope, [record, operation]);
}
Ext.callback(config.callback, scope, [record, operation]);
};
this.proxy.read(operation, callback, this);
}
}
});
于 2012-08-09T16:58:53.120 回答