我刚刚开始学习Extjs,想要实现服务器端查询。我在Exttrs MVC的Contriller中编写了一些这样的代码:
'SearchPanel button[action=select]': {
'click' : function() {
//console.log(Ext.getDom('s_name').value );
console.log(Ext.getCmp('s_studentid').getValue());
var grid = Ext.ComponentQuery.query('studentList')[0];
var store = grid.store;
store.filterBy(function(record) {
//return record.get('name') == '张新武' && record.get('id') == 8;
var s_studentid = Ext.getCmp('s_studentid').getValue();
var s_name = Ext.getCmp('s_name').getValue();
var s_unikey = Ext.getCmp('s_unikey').getValue();
var s_type = Ext.getCmp('s_type').getValue();
var s_sex = Ext.getCmp('s_sex').getValue();
var s_college = Ext.getCmp('s_college').getValue();
var s_major = Ext.getCmp('s_major').getValue();
var s_ethnic = Ext.getCmp('s_ethnic').getValue();
return (s_studentid == "" || record.get('id') == s_studentid)
&&(s_name == "" || record.get('name').indexOf(s_name)>=0)
&&(s_unikey == "" || record.get('name') == s_unikey)
&&(s_type == "" || record.get('type') == s_type)
&&(s_sex == "" || record.get('sex') == s_sex)
&&(s_college == "" || record.get('college') == s_college)
&&(s_major == "" || record.get('major') == s_major)
&&(s_ethnic == "" || record.get('ethnic') == s_ethnic);
console.log('invoke select');
});
}
}
但我发现它是从Extjs商店查询数据,而不是从服务器端查询数据。如何更改我的代码,它可以从服务器端查询数据。
答案 0 :(得分:0)
您需要使用新的paramset重新加载才能实现服务器端过滤
store.load({params: /* all this stuff */})
或类似的..