SmartGWT 2.2 - TileGrid issue
I'm creating a simple web page using TileGrid to display a grid of items for sale. I'm overriding the getTile(int recordNum) method to customize the tile. I want to add a series of small buttons to the tile, for example, a detail button so the user could click the button which would open a small window showing more of the selected product details, an add to cart button, and a checkout button, etc.
Here is the issue: The TileGrid loads the data from the server and draws all the tiles correctly, including my new button, but when I filter the data by selecting a new category from a menu the data is correctly filtered, but the TileGrid does not redraw itself, and is always showing the original tiles.
If I remove the line:
everythings works fine.
I have tried a number of different things, such as:
I've pasted the relevant code below.
My TileGrid definition:
Menu Click Handler
I'm creating a simple web page using TileGrid to display a grid of items for sale. I'm overriding the getTile(int recordNum) method to customize the tile. I want to add a series of small buttons to the tile, for example, a detail button so the user could click the button which would open a small window showing more of the selected product details, an add to cart button, and a checkout button, etc.
Here is the issue: The TileGrid loads the data from the server and draws all the tiles correctly, including my new button, but when I filter the data by selecting a new category from a menu the data is correctly filtered, but the TileGrid does not redraw itself, and is always showing the original tiles.
If I remove the line:
Code:
tile.addChild(button);
I have tried a number of different things, such as:
Code:
// These were tried in the click handler after filtering the data
productGrid.layoutTiles();
productGrid.layoutChildren("FILTER");
productGrid.invalidateCache();
productGrid.markForRedraw();
// Tried this in the getTile method
tile.markForRedraw();
My TileGrid definition:
Code:
productGrid = new TileGrid() {
@Override
public Canvas getTile(int recordNum) {
Canvas tile = super.getTile(recordNum);
if(tile.getChildren().length == 0) {
Button button = new Button("Details");
button.setHeight(20);
button.setWidth(40);
tile.addChild(button);
}
return tile;
}
};
productGrid.setTileWidth(230);
productGrid.setTileHeight(250);
productGrid.setWidth(875);
productGrid.setTop(125);
productGrid.setShowAllRecords(false);
productGrid.setAutoFetchData(true);
productGrid.setAnimateTileChange(true);
productGrid.setLayoutMargin(35);
productGrid.setStyleName("productGrid");
productGrid.setDataSource(productDS);
productGrid.setSelectionType(SelectionStyle.SINGLE);
productGrid.setFields(getFields());
productGrid.setTileValueStyle("tile");
productGrid.setShowEdges(false);
Code:
public void onRecordClick(RecordClickEvent event) {
String selectedNode = event.getRecord().getAttribute("categoryId");
categoryCriteria = new Criteria("categoryId", selectedNode);
DSRequest request = new DSRequest();
request.setTextMatchStyle(TextMatchStyle.EXACT);
productGrid.filterData(categoryCriteria, null, request);
productGrid.scrollToTop();
}
Comment