我正在使用sencha gxt 3.x,Fieldset附带默认的toggleButton,而不是我想显示复选框的按钮。
旧版本的gxt 2.x具有在3.x中删除的fieldSet.setCheckboxToggle(true),是否有一个解决方法来切换带有复选框的字段集?
由于
答案 0 :(得分:0)
public class CheckedFieldSet extends FieldSet {
HBoxLayoutContainer bar = new HBoxLayoutContainer();
CheckBox state = new CheckBox();
@Override
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
bar.add(getCollapseButton());
bar.add(state);
if (isCollapsible()) {
state.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
if (state.getValue()) {
ComponentHelper.doAttach(asWidget());
} else {
ComponentHelper.doDetach(asWidget());
}
}
});
ComponentHelper.doAttach(state);
getAppearance().getToolElement(getElement()).appendChild(bar.getElement());
}
}
public HandlerRegistration addChangeHandler(ChangeHandler handler){
return state.addChangeHandler(handler);
}
public void setActive(boolean state){
this.state.setValue(state, true, true);
}
}