栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Notes

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Notes

文章目录
  • 1. 下拉列表选择
    • 1.1 Action定义获取列表数据的方法
  • 2. 模糊查询
  • 3. Oracle 搜索不区分大小写

1. 下拉列表选择 1.1 Action定义获取列表数据的方法

BrandAction.java

	public String getbrandNameList(){
	     List comboData = new ArrayList();
	     ModelService modelService = (ModelService)SpringContextUtils.getBean("modelService");
	     String sql = "select * from tb_sm_brand_info where 1=1 and brandState = ? ";
	     List>  mapList = modelService.findObjectBySQLQueryToMap(sql, new Object[]{"01"});
	     for(Map ms : mapList){
	      comboData.add(new JsonComboData(ms.get("BRANDNAME"), ms.get("ID")));
	     }
	     super.outputMsg(JsonUtils.object2Json(comboData));
	     return NONE;
	    }

carManage.js
API中添加上边自定义的方法:

 getbrandNameList : "brand!getbrandNameList.action"

修改默认的输入框为下拉框

	{
			layout : "column",	//定义一列数据
			border : false,
			bodyCls : "panel-background-color",
			items : [{
				height: 30,
				columnWidth :1,	//列 宽
				border : false,
				bodyCls : "panel-background-color",
				layout : "form",
					items : [{
					    fieldLabel : "汽车品牌",
					    xtype : "cocomboboxremote",	//下拉框
					    url : API.getbrandNameList,	//调用此方法
					    id : "carBrand",
					    name : "model.carBrand",
					    autoLoad : false,
					    labelWidth: 100,
					    allowBlank : false,
					    blankText : "请选择汽车品牌!",	//未选择内容时的提示内容
					    beforeLabelTextTpl : pointer,
					    editable : true,
					    anyMatch : false,
					    typeAhead : false,
					    forceSelection : false,
					    minChars: 1,
					    listeners : {
					    	focus : function(me, records, opt) {
					     		me.load();
					     	},
					     	select : function(combo, records,eOpts){
					      		Ext.getCmp("brandId").setValue(records[0].data.value);	
					     	}}}]}]}
2. 模糊查询

Action添加方法

	protected void beforeQueryModel(Brand brand) {
		brand.addCustomerQueryCondition("brand.brandName", "like");
	}
3. Oracle 搜索不区分大小写

Action添加方法,覆盖默认的搜索方法

		
	public String queryBrands() {
		JsonMsg msg = new JsonMsg(false);
		List>  resultList = new ArrayList>();
		Brand brand = super.getModel();
		Long count;
		try {
			if (StringUtils.isNotBlank(brand.getBrandName())){
				count = super.getModelService().getCountBySQLQuery("select count(brand.id) from tb_sm_brand_info brand where brand.brandName like ? or  brand.brandName like ?", new Object[]{"%"+ brand.getBrandName().toUpperCase() + "%","%"+ brand.getBrandName().toLowerCase() + "%"});
				resultList = super.getModelService().findObjectBySQLQueryToMapPaging("select brand.* from tb_sm_brand_info brand where brand.brandName like ? or  brand.brandName like ? order by brand.createTime desc ", new Object[]{"%"+ brand.getBrandName().toUpperCase() + "%", "%"+ brand.getBrandName().toLowerCase() + "%"}, this.getPage() - 1, this.getLimit());
			}else{
				count = super.getModelService().getCountBySQLQuery("select count(brand.id) from tb_sm_brand_info brand where 1 = 1", null);
				resultList =  super.getModelService().findObjectBySQLQueryToMapPaging("select brand.* from tb_sm_brand_info brand where 1 = 1 order by brand.createTime desc ", null, this.getPage() - 1, this.getLimit());
			}
			super.outputMsg(JsonUtils.encodeResultListToJson(resultList, count));
			msg.setSuccess(true);
		} catch (Exception e) {
			e.printStackTrace();
			msg.setSuccess(false);
		}
		return NONE;
	}

BrandManage.js修改默认的查询API为

querybrand : "brand!queryBrands.action",

BrandManage.js修改Model的字段名为全大写

Co.defineModel("brand", ["ID","BRANDNAME","BRANDADDRESS","BRANDBELONGCOUNTRY","SETUPDATE","BRANDSTATE"]);

BrandManage.js修改以下字段名为大写

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/396703.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号