小白之-------日常记录
================================================================
Ext 部分:
加载Store
var store = Ext.create('Ext.data.Store', {
autoLoad : true,
fields : [ "id", "goodsTypeName", "removed"],
proxy : {
type : 'ajax',
url : 'searchGoodsType',
reader : {
type : 'json',
root : 'result'
}
}
});
Store加载参数
xtype : 'panel',
id : 'goodsType-panel',
title : '商品类别信息',
plain : true,
style : 'background-color:#dfe8f6;',
items : [ new Ext.FormPanel({
frame : true,
height : '100%',
margin : '5px',
layout: {
type: 'hbox',
align: 'middle'
},
items : [{
xtype : 'panel',
title : '查询条件',
id : 'shop-goodsTypeName',
xtype : 'textfield',
labelAlign : 'right',
width : 300,
fieldLabel : '商品类别名称',
margin : '10 0 0 10',
}, {
xtype : 'button',
text : '查询',
width : 80,
margin : '0 0 0 10',
listeners : {
click : function() {
/**
* 为Store添加筛选参数.
*/
store.getProxy().extraParams.goodsTypeName =
Ext.getCmp('shop-goodsTypeName').getValue();
store.load({
});
}
}
},{
xtype : 'button',
text : '重置',
width : 80,
labelAlign : 'right',
listeners : {
click : function() {
this.up('form').getForm().reset();
}
}
}]
}), grid
后台SQL:
List<String> params = new ArrayList<String>();
String sql = " select id ,"
+ " goods_type_name,"
+ " removed"
+ " from goods_type "
+ " where removed=0";
if (!goodsTypeName.equals("")) {
sql += " and goods_type_name like ?";
params.add("%" + goodsTypeName + "%");
}
sql += " order by id desc";