我有一个位于面板中的图表。我想使用ajax将面板的标题传递给一个php脚本。我已经为我的商店使用了ajax代理。例如,我想知道面板的标题,以便查询正确的数据。以下是我迄今为止所做的工作。
var store = Ext.create('Ext.data.JsonStore', {
fields: ['project', 'accepted', 'rejected', 'deleted', 'undefined'],
proxy: {
type: 'ajax',
url: 'generate_proj.php',
extraParams: {foo: this.idname},
reader: {
type: 'json'
}
},
autoLoad: true,
listeners: {
load: function(obj,records) {
var text = Ext.decode(obj.responseText);
console.log(this.idname);
Ext.each(records,function(rec) {});
}
}
});
在我的php脚本中,我使用$value = $_GET['foo'];
。
我确信我已经接近了,但我找不到任何关于如何更好地利用params的例子或文档。有什么帮助或想法吗?
extraparams
应为extraParams
,驼色大小写。http://docs.sencha.com/ext-js/4-1/#/api/Ext.data.proxy.Server-cfg-extraParams,尽管他们的文档中有一条评论说它不起作用。
一种解决方法是侦听beforeload
事件并从此更改参数http://docs.sencha.com/ext-js/4-1/#/api/Ext.data.AbstractStore-event-beforeload
listeners: {
scope: this
beforeload: function(store, operation) {
operation.params.foo = this.idname;
}
}