Hi,
The folowing code works fine with SmartGWT 4 (v9.0p_2015-07-31/LGPL) but not with SmartGWT 5 (v10.0p_2015-07-31/LGPL). GWT version used is 2.7 and browser is Chrome 44.0.2403.125 m
With SmartGWT 4, ListGrid.getRecord() & ListGrid.getEditedRecord() always return a CustomListGridRecord instance. The problem is that with SmartWT 5 only ListGrid.getRecord() returns a CustomListGridRecord object. ListGrid.getEditedRecord() always returns a ListGridRecord, generating a ClassCastException.
The folowing code works fine with SmartGWT 4 (v9.0p_2015-07-31/LGPL) but not with SmartGWT 5 (v10.0p_2015-07-31/LGPL). GWT version used is 2.7 and browser is Chrome 44.0.2403.125 m
With SmartGWT 4, ListGrid.getRecord() & ListGrid.getEditedRecord() always return a CustomListGridRecord instance. The problem is that with SmartWT 5 only ListGrid.getRecord() returns a CustomListGridRecord object. ListGrid.getEditedRecord() always returns a ListGridRecord, generating a ClassCastException.
Code:
package test.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.types.ListGridEditEvent;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
public class Test implements EntryPoint {
public void onModuleLoad() {
ListGridField nameField = new ListGridField("countryName", "Country");
ListGridField populationField = new ListGridField("population", "Population");
populationField.setType(ListGridFieldType.INTEGER);
final ListGrid countryGrid = new ListGrid();
countryGrid.setFields(nameField, populationField);
countryGrid.setData(new CustomListGridRecord[]{
createRecord("United States", 318000000),
createRecord("China", 1357000000),
});
countryGrid.setCanEdit(true);
countryGrid.setEditEvent(ListGridEditEvent.CLICK);
countryGrid.setEditByCell(true);
countryGrid.addRecordClickHandler(new RecordClickHandler() {
public void onRecordClick(RecordClickEvent event) {
try
{
CustomListGridRecord record = (CustomListGridRecord) countryGrid.getRecord(event.getRecordNum());
}
catch(Exception e)
{
SC.say("getRecord", e.toString());
}
try
{
CustomListGridRecord record = (CustomListGridRecord) countryGrid.getEditedRecord(event.getRecordNum());
}
catch(Exception e)
{
SC.say("getEditedRecord", e.toString());
}
}
});
countryGrid.draw();
}
CustomListGridRecord createRecord(String countryName, int population) {
CustomListGridRecord record = new CustomListGridRecord();
record.setAttribute("countryName", countryName);
record.setAttribute("population", population);
return record;
}
class CustomListGridRecord extends ListGridRecord {}
}