Smartgwt SELECT ALL functionality

喜你入骨 提交于 2019-12-13 04:40:47

问题


Need help regarding.selectall functionality. I have created a form.

DynamicForm form = new DynamicForm();  
final SelectItem category = new SelectItem("category", "Employee Category");  
category.setMultiple(true);  
category.setValueMap("Direct","InDirect","ALL");  
form.setFields(category);  

If i select 'ALL' all three items in picklist should also be selected.if i deselect 'ALL' all three items should be deseleted. need help


回答1:


You can try out the following:

boolean isAllSelected = false; // global variable
SelectItem selectItem = new SelectItem("category", "Employee Category");
selectItem.setMultiple(true);
selectItem.setMultipleAppearance(MultipleAppearance.PICKLIST);
selectItem.setValueMap("Direct","InDirect","ALL");
selectItem.addChangedHandler(new ChangedHandler() {

    @Override
    public void onChanged(ChangedEvent event) {
        if (event.getValue() != null) {
            if (event.getValue().toString().contains("ALL")) {
                if (!isAllSelected) {
                    selectItem.setValues("Direct","InDirect", "ALL");
                    isAllSelected = true;
                }
            } else {
                if (isAllSelected) {
                    selectItem.clearValue();
                }
                isAllSelected = false;
            }
        } else {
            isAllSelected = false;
        }
    }
});

DynamicForm form = new DynamicForm();
form.setSize("800px", "400px");
form.setFields(selectItem);
form.draw();


来源:https://stackoverflow.com/questions/19831660/smartgwt-select-all-functionality

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!