EXT-GWT--ComboBox使用实例

本文详细介绍了如何在EXT-GWT框架中正确使用ComboBox组件,包括配置泛型、设置显示字段及触发更改事件等关键步骤,并提供了一个具体的使用示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近用EXT-GWT写了很多界面,遇到了些问题,现在抽时间把这些问题整理一下,以便忘记时可以参考。

首先来看看EXT-GWT中下拉列表ComboBox的使用:combobox的正确使用必须注意两点:

1:ComboBox<BaseModel>中泛型指定为BaseModel(或其子类简单来说的具有get("[color=red]value[/color]")和set("[color=red]value[/color]",value)这两个方法)BaseModel

2:setDisplayField("[color=red]value[/color]") 方法中颜色相同的关键字必须相同。

使用实例
ListStore<BaseModel> merchantStore = new ListStore<BaseModel>();
merchantStore.add(getMerchant());
ComboBox merchant = new ComboBox<BaseModel>();
merchant.setFieldLabel("商户:");

merchant.setDisplayField("merchant");
merchant.setValue(getMerchant().get(0));//设置初始值
merchant.setStore(merchantStore);

private List<BaseModel> getMerchant() {
/**
* 商户类型
*/
List<BaseModel> list = new ArrayList<BaseModel>();
list = new ArrayList<BaseModel>();
BaseModel bm = new BaseModel();
bm.set("merchant", "法文:箱子(百联店)");
bm.set("key", "1");
list.add(bm);
bm = new BaseModel();
bm.set("merchant", "法文:箱子(人南店)");
bm.set("key", "2");
list.add(bm);
bm = new BaseModel();
bm.set("merchant", "法文:箱子(银都店)");
bm.set("key", "3");
list.add(bm);
bm = new BaseModel();
bm.set("merchant", "法文:箱子(香槟店)");
bm.set("key", "4");
list.add(bm);
return list;

}

相同颜色必须一致。

简单说了下拉列表的使用注意事项后,再来说一说ComboBox的触发事件Events.Change

merchant.addListener(Events.Change, new Listener<ComponentEvent>() {

@SuppressWarnings("unchecked")
public void handleEvent(ComponentEvent be) {

ComboBox<BaseModel> selectBox = (ComboBox) be.component;
String value = selectBox.getValue().get("merchant");

/**
* 事件处理
*/

if ("自定义时段".equals(value)) {
} else {

}

}
});
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值