我使用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);
}
}注意,我不是为每一行创建select项。
在编辑行时,我看到下拉列表中的“一些文本”和“其他文本”,但是当我不编辑值时,我看到的是相应的键而不是值。
我搜索了javadoc,但是找不到任何东西,如果没有明确的内容,请询问,我会添加。
发布于 2012-08-21 21:13:17
最后,用DataSource找到一个解决方案,并将其设置在SelectItem的optionDataSource中,并将displayField和valueField设置为相应的字段。
然后,当字段未被编辑时,我在ListGridField中设置了一个自定义CellFormatter,它返回正确的数据(这也包括为其他值返回适当的数据)。
我很肯定有一种更简单的方法,但这种方式对我来说是有效的,所以我现在就把它留在这里。
发布于 2012-08-21 19:31:08
您需要将setValueMap()放在ListGridField上,SelectItem也在其中出现(具有相同的valueMap)。
https://stackoverflow.com/questions/12046287
复制相似问题