ListGrid.setEditorCustomizer in SmartGWT [duplicate]

孤者浪人 提交于 2020-02-01 07:57:25

问题


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.


回答1:


You need to setValueMap() on the ListGridField where the SelectItem appears as well (with the same valueMap).




回答2:


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.



来源:https://stackoverflow.com/questions/12046287/listgrid-seteditorcustomizer-in-smartgwt

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