在实际开发中我们免不了有个单独的页面对一张表中的数据进行必要条件的筛选、 查询、excel文件导出等操作。相比之下,我们对用户以确定的输入条件需要传递到后台处理查询正确的数据。以下适用于extjs4.X的查询条件传递。
前台sotre中可以这样写:
Ext.define('panel_model',{
extend: 'Ext.data.Model',
fields: ['ID','NAME','ADDRESS','TELPHONE']
});
var store=Ext.create('Ext.data.Store',{
storeId:'main_store',
autoLoad: true,
model: 'panel_model',
pageSize: 10,
remoteSort: true,
proxy: {
type: 'ajax',
url: main_Url+'getPersonInfo',
reader: {
type: 'json',
root:'data',
totalProperty: 'sum'
}
},
sorters: [
{
property: '',
direction: ''
}
]
});
/* 分页查询条件传递 */
store.on('beforeload',function (store,options){
var new_params={
name : Ext.getCmp('name').getValue() ,
address:Ext.getCmp('address').getValue()};
Ext.apply(store.proxy.extraParams,new_params);
});
java后台获取查询参数的方法:
String name = request.getParameter("name");
String address = request.getParameter("address");