SmartGWT中的ListGrid.setEditorCustomizer [英] ListGrid.setEditorCustomizer in SmartGWT

查看:113
本文介绍了SmartGWT中的ListGrid.setEditorCustomizer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:

Smartgwt selectitem键值问题

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



类似这样:

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



<请注意,我并没有为每一行创建选择项。



E在编辑行时非常有效,我在下拉列表中看到一些文本和其他文本,但是当我没有编辑该值时,我会看到相应的键而不是值。



我已经搜索了javadoc,但找不到任何东西,如果有任何内容不明确,请询问我将添加的内容。

解决方案使用 DataSource 找到一个解决方案,并将其设置在 SelectItem 的optionDataSource中,然后设置displayField和valueField到相应的字段。然后,当字段没有被编辑时,在 ListGridField 我设置了返回正确数据的自定义 CellFormatter (这也涉及为其他值返回适当的数据)。



我敢肯定,可能有一种更简单的方式,但这种方式对我来说很有用,所以我现在就会这样。


Possible Duplicate:
Smartgwt selectitem key value issue

I'm using setEditorCustomizer to set custom editors for some fields in a ListGrid, my specific problem is on a SelectItem

Something like this:

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

Note that I'm not creating select items for every row.

Everything works great when editing the row, I see "some text" and "other text" in the dropdown but when I'm not editing the value I see the corresponding key instead of the value.

I have searched the javadoc but couldn't find anything, if anything is not explicit please ask and I will add.

解决方案

Ended up finding a solution with a DataSource and setting it in the optionDataSource of the SelectItem and setting displayField and valueField to the respective fields.

And then for when the field is not being edited, in the ListGridField I set a custom CellFormatter that returned the proper data (this involves returning proper data for the other values too).

I'm pretty sure there may be a simpler way, but this way it works for me so I will leave it like that for now.

这篇关于SmartGWT中的ListGrid.setEditorCustomizer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆