1

我目前正在设置一个ListGrid带有过滤器的过滤器,但是在为具有多个项目选择的字段实现过滤器时遇到问题。

这是我想要实现的示例:

我有ListGrid这些价值观:

_________________
|Fruits Selected|
|_______________|
|Apple          |
|Apple,Orange   |
|Orange         |
|_______________|

当我尝试在我的“多项目过滤器”中过滤并选择橙色时,我希望在我的网格上看到这个:

_________________
|Fruits Selected|
|_______________|
|Apple,Orange   |
|Orange         |
|_______________|

但相反,我只看到这个:

_________________
|Fruits Selected|
|_______________|
|Orange         |
|_______________|

我是否解释了预期的输出错误?如果是这样,有没有办法可以自定义处理多个项目过滤器的方式?

另一件事,我正在使用GenericGwtRpcDataSource这个论坛。希望这不是问题。

以下是要求的示例代码: DataSource

public class FruitLocalDS extends DataSource {

private static FruitLocalDS instance = null;

public static FruitLocalDS getInstance() {
    if (instance == null) {
        instance = new FruitLocalDS("supplyItemLocalDS");
    }
    return instance;
}

public FruitLocalDS(String id) {
    setID(id);

    DataSourceEnumField fruitNameField = new DataSourceEnumField(
            "fruitNames", "Fruit Name");
    fruitNameField.setMultiple(true);
    fruitNameField.setValueMap("Apple", "Guyabano", "Pineapple", "Orange",
            "Grapes");

    setFields(fruitNameField);
    setClientOnly(true);
    setTestData(Fruit.getDummyRecords());
}}

列表网格记录

public class Fruit  extends ListGridRecord {

public Fruit(String[] fruitNames) {
    setFruitNames(fruitNames);
}

public void setFruitNames(String[] fruitNames) {
    setAttribute("fruitNames", fruitNames);
}

public String getFruitName() {
    return getAttribute("fruitNames");
}

public static Fruit[] getDummyRecords() {
    return new Fruit[] {
            new Fruit(new String[]{"Orange"}), 
            new Fruit(new String[]{"Apple", "Orange"}),
            new Fruit(new String[]{"Guyabano","Orange"}),
            new Fruit(new String[]{"Pineapple","Orange"}),
    };
}}

入口点

public class MultiItemTest implements EntryPoint {
public void onModuleLoad() {
    final DataSource dataSource = FruitLocalDS.getInstance();

    ListGrid listGrid = new ListGrid();
    listGrid.setWidth(1000);
    // listGrid.setAutoFitData(Autofit.VERTICAL);
    listGrid.setHeight(224);
    listGrid.setDataPageSize(50);
    listGrid.setDataSource(dataSource);
    listGrid.setShowFilterEditor(true);
    listGrid.setCanEdit(true);
    listGrid.setAutoFetchData(true);
    listGrid.setEditEvent(ListGridEditEvent.DOUBLECLICK);

    listGrid.setShowRowNumbers(true);
    listGrid.setFilterOnKeypress(true);
    listGrid.setFetchDelay(1);

    listGrid.draw();
}}

当您尝试在过滤器中选择“橙色”时,它只会显示:

Orange

我期望的是:

Apple,Orange
Guyabano,Orange
Orange
Pineapple, Orange
4

0 回答 0