多项目列表网格过滤

时间:2013-01-03 17:54:19

标签: gwt smartgwt gwt-rpc listgrid

我目前正在使用过滤器设置ListGrid,但在为多项选择的字段实施过滤器方面存在问题。

以下是我想要实现的一个例子:

我有ListGrid这些值:

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

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

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

但相反,我只看到了这个:

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

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

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

以下是请求的示例代码: 的数据源

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());
}}

ListGridRecord

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"}),
    };
}}

的EntryPoint

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

0 个答案:

没有答案