加载存储后,extjs combobox不会更新
在我的MVC应用程序中,我有一个如下定义的控制器:加载存储后,extjs combobox不会更新,combobox,extjs4,store,Combobox,Extjs4,Store,在我的MVC应用程序中,我有一个如下定义的控制器: Ext.define('NE.controller.MyController', { extend: 'Ext.app.Controller', stores : [...'StoreAgents'..], views: [ ...'MyView'...], // * alias w_view init: function() { this.control({ 'w_v
Ext.define('NE.controller.MyController', {
extend: 'Ext.app.Controller',
stores : [...'StoreAgents'..],
views: [ ...'MyView'...], // * alias w_view
init: function() {
this.control({
'w_view': {
render: function() { this.getStore('StoreAgents').load(); }
}
});
}
});
{
xtype: 'combobox',
name : 'id_agent',
forceSelection: true,
fieldLabel: 'Agent',
store: 'StoreAgents',
queryMode: 'local',
displayField: 'name',
valueField: 'id'
}
在视图MyView中,我有一个如下定义的组合框:
Ext.define('NE.controller.MyController', {
extend: 'Ext.app.Controller',
stores : [...'StoreAgents'..],
views: [ ...'MyView'...], // * alias w_view
init: function() {
this.control({
'w_view': {
render: function() { this.getStore('StoreAgents').load(); }
}
});
}
});
{
xtype: 'combobox',
name : 'id_agent',
forceSelection: true,
fieldLabel: 'Agent',
store: 'StoreAgents',
queryMode: 'local',
displayField: 'name',
valueField: 'id'
}
我希望每次呈现视图时都会更新组合框列表,我错了吗?
当前,组合框仍然没有任何选项,即使我(通过firebug)看到应用程序触发了正确返回所有代理数据的请求
此外,我注意到,每当我浏览另一个由另一个控制器管理的视图时,它会声明另一个StoreAgent并调用其load()方法。。好吧,如果我回来,现在我看到组合框填充
我错过了什么?
多谢各位
编辑:
我注意到存储是
{buffered:true}
。如果我将其切换为false,则存储触发“datachange”事件;否则它就不会。所以现在的问题是:如果启用了缓冲,为什么load()不会触发“datachange”?这可能是由于过滤掉的情况。如果在加载存储之前用值填充组合框,则会在存储上放置一个过滤器,在值存在之前过滤掉所有值,然后在添加新记录时也不会显示这些值。试试这个
init: function() {
this.control({
'w_view': {
render: function() { this.getStore('StoreAgents').load();
this.getStore('StoreAgents').clearFilter();}
}
});
}
谢谢,我试过了,但还是没法用。查看firebug,load()方法触发应用程序的第一个ajax请求;因此,存储不太可能启用了以前的过滤器。