In a situation where I have a ListGrid with getExpansionComponent overridden, I would like to refresh the content of the expanded component. I figured that I can refresh a row of a ListGrid using refreshRow, but the grid probably know if it's necessary to update the expanded component as there isn't directly a field related to that. Collapsing the record and expanding it again redraws it ofcourse.
Take this example:
This renders a grid which is expandable, don't mind the content of the expansion component for now :). But as you can see, in a Timer the content is updated which is used in the expanded component - and should also be refreshed.
Is there a way to redraw the expanded component of a record? I'm using SmartGWT 2.4, which contains SmartClient 8.0 2010-12-31.
Thanks in advance for your help!!
Take this example:
Code:
addChild(grid = new ListGrid() {
@Override
protected Canvas getExpansionComponent(ListGridRecord record) {
/*
* This is just an example of what the expanded content could be
*/
Canvas c = new Canvas();
c.setContents(record.getAttribute("expandedContent"));
c.setHeight(20);
c.setWidth100();
return c;
}
{
setWidth100();
setHeight100();
setCanExpandRecords(true);
setFields(
new ListGridField("id"),
new ListGridField("name")
);
/*
* Add some random data
*/
setData(new ListGridRecord[]{
new ListGridRecord() {{
setAttribute("id", "1");
setAttribute("name", "Row one");
setAttribute("expandedContent", "This content is for the expanded component of row one");
}},
new ListGridRecord() {{
setAttribute("id", "2");
setAttribute("name", "Row two");
setAttribute("expandedContent", "This content is for the expanded component of row two");
}}
});
}
});
/*
* After 2 seconds, we'll update some data
*/
(new Timer() {
@Override
public void run() {
Record r = grid.getRecord(0);
r.setAttribute("name", "New name for row one");
r.setAttribute("expandedContent", "New content is for the expanded component of row one");
grid.refreshRow(0);
}
}).schedule(2000);
Is there a way to redraw the expanded component of a record? I'm using SmartGWT 2.4, which contains SmartClient 8.0 2010-12-31.
Thanks in advance for your help!!
Comment