gpt4 book ai didi

java - smartgwt 在 ComboBoxItem 中添加空白行或允许用户设置空白值

转载 作者:行者123 更新时间:2023-12-02 03:32:35 24 4
gpt4 key购买 nike

我正在尝试在 smartgwt 的 ComboBoxItem 中添加带有 null 值的空白行,该值已绑定(bind)到来自数据库的数据源。

我也尝试过服务层、 Controller 层和数据库的改变,但我的前辈不建议这样做。

我只需要在 UI 层 上进行更改。

最佳答案

看看Special Values ComboBox SmartGWT 展示演示。我认为它可以满足你的要求。

这里是摘自该演示代码的摘录(尽管我建议您查看它并研究代码以了解最适合您的情况):

LinkedHashMap<String,String> hashMap = new LinkedHashMap<String,String>();  
hashMap.put("**EmptyValue**", "None");
hashMap.put("-1", "Not Applicable");

ComboBoxItem comboBoxItem = new ComboBoxItem();
comboBoxItem.setName("filteredCombo");
comboBoxItem.setTitle("Choose an item (ComboBox)");
comboBoxItem.setAddUnknownValues(false);
comboBoxItem.setOptionDataSource(ItemSupplyXmlDS.getInstance());
comboBoxItem.setDisplayField("itemName");
comboBoxItem.setValueField("itemID");
comboBoxItem.setPickListWidth(300);
comboBoxItem.setPickListFields(skuField, itemNameField);
comboBoxItem.setSpecialValues(hashMap);
comboBoxItem.setSeparateSpecialValues(true);

关于java - smartgwt 在 ComboBoxItem 中添加空白行或允许用户设置空白值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37880753/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com