Ok, I was initially hoping to find out whether it was a known issue or not.
In distilling it down to a very simple case, matters got worse. In this sample, I can’t even cause ListGrid.updateRecordComponent to be called by refreshing the list fields. Anyway, Using this sample, edit a username, press enter, and note that the text on the canvas in the first column is not updated. Sort a column, and notice it gets updated.
import com.google.gwt.core.client.EntryPoint;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
public class Test implements EntryPoint {
@Override
public void onModuleLoad() {
Canvas canvas = new Canvas();
final ListGrid myList = new ListGrid() {
protected Canvas createRecordComponent(final ListGridRecord record, Integer colNum) {
if (this.getFieldName(colNum).equals("abc")) {
Canvas c = new Canvas();
c.setContents(record.getAttributeAsString("userName"));
return c;
}
return null;
}
@Override
public Canvas updateRecordComponent(ListGridRecord record, Integer colNum, Canvas component, boolean recordChanged) {
if (this.getFieldName(colNum).equals("abc")) {
Canvas c = component;
c.setContents(record.getAttributeAsString("userName"));
return c;
}
return component;
}
};
myList.setCanEdit(true);
myList.setShowRecordComponents(true);
myList.setShowRecordComponentsByCell(true);
myList.setHeight(300);
myList.setShowAllRecords(true);
ListGridField widgetField = new ListGridField("abc", "Some Widget");
widgetField.setCanEdit(false);
ListGridField nameField = new ListGridField("userName", "Name");
myList.setFields(new ListGridField[] {widgetField, nameField});
ListGridRecord joe = new ListGridRecord();
joe.setAttribute("userName", "joe");
ListGridRecord frank = new ListGridRecord();
frank.setAttribute("userName", "frank");
ListGridRecord bob = new ListGridRecord();
bob.setAttribute("userName", "bob");
myList.setData(new ListGridRecord[] {joe, frank, bob});
canvas.addChild(myList);
canvas.draw();
}
}
Like others suggested sorting fixes the problem but when we are implementing sort on listGrid columns then the updateRecordComponent is calling unnecessarily giving unpleasant placement of recordComponents.
Can anyone has better solution to the above problem?