【问题标题】:ListGrid.setEditorCustomizer in SmartGWT [duplicate]SmartGWT 中的 ListGrid.setEditorCustomizer [重复]
【发布时间】:2012-08-22 05:13:17
【问题描述】:

可能重复:
Smartgwt selectitem key value issue

我正在使用 setEditorCustomizer 为 ListGrid 中的某些字段设置自定义编辑器,我的具体问题是在 SelectItem 上

类似这样的:

grid.setEditorCustomizer(new ListGridEditorCustomizer() {
    public FormItem getEditor(ListGridEditorContext context) {
         SelectItem selectItem = new SelectItem();
         LinkedHashMap<String, String> valuesMap = new LinkedHashMap<String, String>();
         valuesMap.put("0","some text");
         valuesMap.put("1","other text");
         selectItem.setValueMap(valuesMap);
    }
}

请注意,我不会为每一行创建选择项。

编辑行时一切正常,我在下拉列表中看到“一些文本”和“其他文本”,但当我不编辑值时,我看到的是相应的键而不是值。

我已经搜索了javadoc但找不到任何东西,如果有什么不明确的,请询问,我会补充。

【问题讨论】:

    标签: java gwt smartgwt


    【解决方案1】:

    您需要在也出现 SelectItem 的 ListGridField 上 setValueMap()(具有相同的 valueMap)。

    【讨论】:

    • 试过了,但还是拿到了钥匙。
    【解决方案2】:

    最终找到了带有DataSource 的解决方案并将其设置在SelectItem 的optionDataSource 中,并将displayField 和valueField 设置为相应的字段。

    然后,当该字段未被编辑时,我在ListGridField 中设置了一个自定义CellFormatter,它返回了正确的数据(这也涉及为其他值返回正确的数据)。

    我很确定可能有更简单的方法,但这种方法对我有用,所以我现在就这样吧。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-14
      相关资源
      最近更新 更多