GXT GridFilters问题

时间:2015-12-10 10:48:09

标签: java filter gxt

我改变了我的问题。我在我的网络应用上尝试GridFilters。但它不适用于“多个过滤器”。 当我只添加一个过滤器时,它可以工作。

仅举例来说

filters.addFilters(classFilter);

或者

filters.addFilters(studentNameFilter);

但不适合

filters.addFilters(classFilter);
filters.addFilters(studentNameFilter);

我试图关注https://www.sencha.com/examples-2/#filtergrid,但似乎对我不起作用。我该如何解决这个问题?

这是我的编码:

ColumnModel cm = getColumnModel();
ContentPanel cp = new ContentPanel();
cp.setBodyBorder(true);  
cp.setHeadingHtml("Filter Grid");
cp.setLayout(new FitLayout());  
cp.setSize(660, 300);

GridFilters filters = new GridFilters();  
filters.setLocal(true);

StringFilter studentNameFilter = new StringFilter(StudentModelData.STUDENT_NAME);
StringFilter classFilter = new StringFilter(StudentModelData.CLASS);

filters.addFilter(studentNameFilter);
filters.addFilter(classFilter);

ListStore<StudentModelData> store = new ListStore<StudentModelData>();  
List<StudentModelData> tempStudentModelData = new ArrayList<StudentModelData>();
List<ModelData> modelData = event.<List<ModelData>> getData();
for (int i = 0; i < modelData.size(); i++) {
    tempStudentModelData.add((StudentModelData) modelData.get(i));
    store.add(tempStudentModelData.get(i));
}
final Grid<StudentModelData> grid = new Grid<StudentModelData>(store, cm);
grid.getView().setForceFit(true);  
grid.setStyleAttribute("borderTop", "none");  
grid.setAutoExpandColumn("name");  
grid.setBorders(false);  
grid.setStripeRows(true);  
grid.setColumnLines(true);  
grid.addPlugin(filters);  
cp.add(grid);
container.add(cp);

ColumnModel

public ColumnModel getColumnModel() {
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
configs.add(new ColumnConfig(StudentModelData.STUDENT_NAME, "Student Name", 130));
configs.add(new ColumnConfig(StudentModelData.CLASS, "Class", 70));
return new ColumnModel(configs);
}

0 个答案:

没有答案