0

I have a DataSource class that extends com.smartgwt.client.data.DataSource. I have several DataSourceTextFields in it that show some Strings, and I need to also show an image button in one of the columns. The problem is that if I add another field like that:

DataSourceField icon = new DataSourceField("name", FieldType.ANY, "title");
setFields(/*the other fields*/, icon);

and then upon Fetch I add all values like that:

ArrayList<Record> records = new ArrayList<Record>();
// add all records in iteration, an then add the icon one
ListGridRecord iconRecord = new ListGridRecord();

ImgButton icon = new ImgButton();
icon.setSrc("theSrc/icon.png");
// icon.addClickHandler to execute some action

iconRecord.setAttribute("name", icon);
records.add(iconRecord);

response.setData(records.toArray(new Record[records.size()]));
processResponse(requestId, response);

All of this produces a com.google.gwt.core.client.JavaScriptException: (null): null - the table shows, but with empty rows and with this error in the Console (with no more details). I also tried to put the ImgButton in a HLayout, but I get the same error. I also tried to create a DataSourceImageField for the purpose, but then I have other errors. Could you, please, help? Thank you.

Bubolina
  • 141
  • 2
  • 16
  • Try changing `FieldType.ANY` to `FieldType.IMAGE`. Also instead of `ImgButton` try using `Image`. – RAS Oct 22 '13 at 06:34
  • I tried, it didn't work. – Bubolina Nov 07 '13 at 16:25
  • As I couldn't find a way to add image into a `DataSourceField`, the workaround I did was to override `protected Canvas createRecordComponent(ListGridRecord record, Integer colNum)` method for the column I needed, adding into it a `HLayout` with an `ImgButton`. – Bubolina Nov 07 '13 at 16:35

0 Answers0