简体   繁体   中英

GXT Resize Grid and FieldSet when grid store is filtered

I have a fieldset with a grid inside. I'm applying a filter to the grid store and want both the fieldset and the grid to resize when the filter is applied. I have the listener on the store but I can't for the life of me figure out how to resize both components.

I'm using GXT 2.4

Here's some sample code to give context:

final FieldSet fieldSet = new FieldSet();
fieldSet.setHeading("Example");
fieldSet.setCollapsible(true);
fieldSet.setCheckboxToggle(true);
fieldSet.setExpanded(false);
mainFieldSet.add(fieldSet,new RowData(-1,-1,new Margins(10,0,0,0)));

ListStore<MyModel> store = new ListStore<MyModel>();
store.add(myModels);

CheckBoxSelectionModel<MyModel> sm = new CheckBoxSelectionModel<MyModel>();

List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
columns.add(sm.getColumn());
ColumnConfig column = new ColumnConfig("id", "Id", 40);
column.setSortable(false);
columns.add(column);
column = new ColumnConfig("name", "Label",280);
column.setSortable(false);
columns.add(column);

final Grid<MyModel> grid = new Grid<MyModel>(store, new ColumnModel(columns));
grid.addPlugin(sm);
grid.setBorders(true);
grid.setSelectionModel(sm);
fieldSet.add(grid);

grid.getStore().addStoreListener(new StoreListener<MyModel>() {
    public void storeFilter(StoreEvent<MyModel> se) {
        // Need something here to resize both grid and fieldSet
    }
});

Cracked it! The fieldSet and grid both need to have setAutoHeight(true) and fire the following events from the StoreListener :

grid.getStore().addStoreListener(new StoreListener<OptionModel>() {
  public void storeFilter(StoreEvent<OptionModel> se) {
    questionFieldSet.fireEvent(Events.Expand);
    questionFieldSet.fireEvent(Events.Resize);
  }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM