本文介绍了Smartgwt选择所有功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要帮助about.selectall功能。我创建了一个表单。

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);

如果我选择'ALL',则选取列表中的所有三个项目也应该被选中。如果我取消选择'ALL '所有三个项目都应该取消。需要帮助

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

推荐答案

您可以尝试以下操作:

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();

这篇关于Smartgwt选择所有功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 19:04