[前端]-ExtJs 有条件的查询(store加载参数进行查询)

小白之-------日常记录

查询全部

带条件模糊查询

================================================================
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";
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值