我正在尝试在 SelectItem 组件中列出一个表。我为此目的使用 ListGrid 组件。这是代码:
final ListGrid brandGrid = new ListGrid();
ListGridField nameField = new ListGridField("name");
ListGridField descriptionField = new ListGridField("description");
ListGridField detailField = new ListGridField("detail");
final SelectItem filterList = new SelectItem();
filterList.setDisplayField("name");
filterList.setValueField("description");
filterList.setPickListWidth(400);
filterList.setOptionDataSource(myDataSource);
filterList.setPickListFields(nameField, descriptionField);
filterList.setPickListProperties(brandGrid);
filterList.setDefaultValue(record.getAttributeAsString("name"));
filterList.setShowTitle(false);
filterList.setStartRow(false);
以及 myDataSource 实例的 DataSource 代码(我DataSource myDataSource
在使用之前调用此方法来初始化类属性SelectItem filterList
):
private DataSource getBrandData(List<BrandDB> result){
DataSource ds = new DataSource();
DataSourceTextField id = new DataSourceTextField();
id.setName("idBrand");
id.setPrimaryKey(true);
DataSourceTextField name = new DataSourceTextField();
name.setName("name");
DataSourceTextField description = new DataSourceTextField();
description.setName("description");
ds.setFields(id, nazov, popis);
ds.setClientOnly(true);
for(int i = 0; i < result.size(); i++){
Record rc = new Record();
rc.setAttribute("idBrand", result.get(i).getIdBrand()+"");
rc.setAttribute("name", result.get(i).getName());
rc.setAttribute("description", result.get(i).getDescription());
ds.addData(rc);
}
return ds;
}
问题是description
我的数据源中的值在多个地方具有相同的值(这些值的 id 和名称不同)。我得到以下错误:
TMR0:WARN:fetchMissingValues:isc_SelectItem_1:Deriving valueMap for 'description' from dataSource based on displayField 'name'. This dataSource contains more than one record with description set to Not defined with differing name values. Derived valueMap is therefore unpredictable.
任何想法如何设置 SelectItem 以接受这些重复值?非常感谢您的回答。:)