I currently have a ListGrid using a RPC Datasource, when editing I have the columns with FK’s set to use a Custom SelectItem with an RPC Datasource.
The data is retrieve perfectly however when I map my FK that is the only thing that shows during editing, but I need a description field to show instead.
I have tried setting ValueField and DisplayField in my SelectItem to no avail:
WebSelectItem
WebListGridDS ds = new WebListGridDS();
ds.setID("weblgds");
setValueField("weblgds.websid");
setDisplayField("weblgds.dsc");
setOptionDataSource(ds);
setAutoFetchData(true);
intField = new DataSourceIntegerField("websid");
intField.setCanEdit(true);
WebSelectItem wsi = new WebSelectItem();
intField.setEditorType(wsi);
intField.setForeignKey("weblgds.websid");
addField(intField);
intField = new DataSourceIntegerField("websid");
intField.setCanEdit(true);
WebSelectItem wsi = new WebSelectItem();
intField.setEditorType(wsi);
intField.setForeignKey("weblgds.websid");
addField(intField);
Field names must be valid identifiers (no dots). It’s not clear what objects some of those methods are being called on, please don’t post incomplete code samples. For any further issues please see the working sample in the Showcase and check the Developer Console for possible warnings.
Trying to use the DeveloperConsole, complete code attached
I’m on SmartGWT 1.1 and GWT 1.6.4
Browser : Hosted Mode on Windows via Eclipse with MyEclipse
I don’t see any errors in the Results Tab for Logging..should I look somewhere else in the tool?
WebListGridDS
public class WebListGridDS extends GWTRPCDataSource<WebRecord> {
public WebListGridDS() {
//Replace with actual RPC Service
super(SGWTWebService.Impl.getInstance());
DataSourceIntegerField intField = new DataSourceIntegerField("websid");
intField.setPrimaryKey(true);
intField.setCanEdit(false);
addField(intField);
DataSourceTextField textField = new DataSourceTextField("dsc");
textField.setCanEdit(true);
addField(textField);
}
protected WebRecord copyValues(Record from) {
WebRecord to = new WebRecord();
to.setWebsid(from.getAttributeAsInt("websid"));
to.setDsc(from.getAttributeAsString("dsc"));
return to;
}
protected Record copyValues(WebRecord from) {
Record to = new ListGridRecord();
to.setAttribute("websid", from.getWebsid());
to.setAttribute("dsc", from.getDsc());
return to;
}
protected Record getEditedRecord(DSRequest request) {
// Retrieving values before edit
JavaScriptObject oldValues = request.getAttributeAsJavaScriptObject ("oldValues");
// Creating new record for combining old values with changes
Record newRecord = new ListGridRecord ();
// Copying properties from old record
JSOHelper.apply (oldValues, newRecord.getJsObj ());
// Retrieving changed values
JavaScriptObject data = request.getData ();
// Apply changes
JSOHelper.apply (data, newRecord.getJsObj ());
return newRecord;
}
}
WebSelectItem
public class WebSelectItem extends SelectItem {
public WebSelectItem() {
super();
WebListGridDS ds = new WebListGridDS();
ds.setID("weblgds");
setValueField("websid");
setDisplayField("dsc");
setEmptyPickListMessage("No data in table");
ListGridField websidField = new ListGridField("websid");
ListGridField dscField = new ListGridField("dsc");
setPickListFields(websidField, dscField);
setOptionDataSource(ds);
setAutoFetchData(true);
}
}
MemberListGridDS
public class MemberListGridDS extends GWTRPCDataSource<MemberRecord> {
public MemberListGridDS() {
//Replace with actual RPC Service
super(SGWTMemberService.Impl.getInstance());
DataSourceIntegerField intField = new DataSourceIntegerField("mbrid");
intField.setPrimaryKey(true);
intField.setCanEdit(false);
addField(intField);
intField = new DataSourceIntegerField("websid");
intField.setCanEdit(true);
WebSelectItem wsi = new WebSelectItem();
intField.setEditorType(wsi);
intField.setForeignKey("weblgds.websid");
addField(intField);
}
protected MemberRecord copyValues(Record from) {
MemberRecord to = new MemberRecord();
to.setMbrid(from.getAttributeAsInt("mbrid"));
to.setWebsid(from.getAttributeAsInt("websid"));
return to;
}
protected Record copyValues(MemberRecord from) {
Record to = new ListGridRecord();
to.setAttribute("mbrid", from.getMbrid());
to.setAttribute("websid", from.getWebsid());
return to;
}
protected Record getEditedRecord(DSRequest request) {
// Retrieving values before edit
JavaScriptObject oldValues = request.getAttributeAsJavaScriptObject ("oldValues");
// Creating new record for combining old values with changes
Record newRecord = new ListGridRecord ();
// Copying properties from old record
JSOHelper.apply (oldValues, newRecord.getJsObj ());
// Retrieving changed values
JavaScriptObject data = request.getData ();
// Apply changes
JSOHelper.apply (data, newRecord.getJsObj ());
return newRecord;
}
}
It would be best if you can create a standalone project that we can run locally without any modifications to reproduce the problem. You can either attach it here or create an issue and attach the standalone testcase.
My Test Case is around 25MB so since the Forum doesn’t allow that size or rar type I’ll assume I need to create an issue could you direct me to where I would do that?
Can you try doing this without creating a subclass - just pass an instance of SelectItem in which you have called various setters with the same values you are currently initializing via your subclass constructor.
intField = new DataSourceIntegerField("websid");
intField.setCanEdit(true);
WebSelectItem wsi = new WebSelectItem();
intField.setEditorType(si);
intField.setForeignKey("weblgds.websid");
addField(intField);
to
intField = new DataSourceIntegerField("websid");
intField.setCanEdit(true);
SelectItem si = new SelectItem();
WebListGridDS ds = new WebListGridDS();
ds.setID("weblgds");
si.setValueField("websid");
si.setDisplayField("dsc");
si.setEmptyPickListMessage("No data in table");
ListGridField websidField = new ListGridField("websid");
ListGridField dscField = new ListGridField("dsc");
si.setPickListFields(websidField, dscField);
si.setOptionDataSource(ds);
si.setAutoFetchData(true);
intField.setEditorType(si);
intField.setForeignKey("weblgds.websid");
addField(intField);
Still only show the websid field instead of the dsc or both.