extjs入门小记()

想要在grid里实现精确查询,一直找不到方法,和朋友交流中得知可以用覆盖url的方式重新load store,遇到了以下问题:

Store里面的fields属性

fields : ["stuID","stuName", "stuAge", "stuHeight", "stuWeight", "schName"]

 

1.GET方式传到后台的值自动添加逗号

Cotroller里面点击查询按钮重新load grid:

search : function(button) {
            var stuID = Ext.getCmp("accur").getValue(); //取得输入框里的值
            var grid = button.up('grid');
            
            if(stuID != null) {                                
                grid.store.load({
                    url:contextPath + "stu/accurate?stuID=" + stuID
                });
            }
        }

 这是因为load的时候会把没有值的其他属性也一并传到后台,而多个参数之间会自动加逗号隔开

 

2.POST方式

accurSearch : function(button) {
	var stuID = Ext.getCmp("accur").getValue();
	var grid = button.up('grid');
				
	if(stuID != ""&&stuID != null) {
		//debugger
		Ext.Ajax.request({
			//url : contextPath + "stu/accurate?stuID=" + stuID,	//GET方式传递参数
			url: contextPath + "stu/accurate",,
			params:{stID:stuID},	//必须是JSON格式					
			success : function(response, options) {						
				grid.store.removeAll();
				var rrt = response.responseText;
				var stu = Ext.JSON.decode(rrt);
				grid.store.add(stu)
			}					
		});
	}else {
		grid.getStore().currentPage = 1;
		grid.getStore().load();
	}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值