0

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 を設定する方法はありますか? 回答ありがとうございます。:)

4

1 に答える 1

0

問題が解決しました:

エラーは次のコード行にあります。

filterList.setValueField("description");

説明は一意ではないため、SelectItem コンポーネント内の値フィールドにすることはできません。このコード行のみを次のように編集する必要があります。

filterList.setValueField("idBrand");

idBrandは、DataSource で主キーとして定義されているため、一意であり、SelectItem はその値フィールドを一意に識別し、フィルターを作成できます。

于 2012-09-30T09:26:19.230 に答える