Datasource Foreign Key via ListGrid with SelectItem

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);

ListGrid Datasource:

intField = new DataSourceIntegerField("websid");
intField.setCanEdit(true);
WebSelectItem wsi = new WebSelectItem();
intField.setEditorType(wsi);
intField.setForeignKey("weblgds.websid");
addField(intField);

Any ideas would be appreciated.

See setPickListFields().

I tried this am I doing something wrong?

I added the ListGridFields as below (do I need to add them some other way?):

WebSelectItem

WebListGridDS ds = new WebListGridDS();
ds.setID("weblgds");
setValueField("weblgds.websid");
setDisplayField("weblgds.dsc");

ListGridField websidField = new ListGridField("weblgds.websid");
ListGridField dscField = new ListGridField("weblgds.dsc");
setPickListFields(websidField, dscField);

setOptionDataSource(ds);
setAutoFetchData(true);

ListGrid Datasource:

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;
	}
}

No Errors in Debug Console

Anyone else have any ideas on this…is it a bug?

Help?

Isomorphic do you have any other suggestions, can I provide you with something I haven’t already?

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.

Would you prefer compiled or as an Eclipse Project?

I can compile it into JavaScript or create an Eclipse Project what would be easier for you to test with?

Thank you,

Just an Eclipse project would be fine.

Test project

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?

Thank you,

Try creating an issue in google code and attach the testcase.

Tried but failed

I’ve tried creating an issue but it won’t allow seems the upload is too big maybe?

I have the following items that make it a bit large:

gwt*.jar’s
smartclient*.jar’s
sc directory for skins

should I remove something?

Thank you,

Yes, you can exclude the gwt and smartclient jars / skins.

Thank you issue 281 created

http://code.google.com/p/smartgwt/issues/detail?id=281

Issue Posted 281

Have you heard any word on this?

I posted an issue but it doesn’t look like it was looked at or if it really is an issue or some other problem.

I would appreciate any feedback.

Thank you for any help,

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.

Tried without the subclass, no luck

Change my code in MemberListGridDS from:

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.

(This is what you wanted me to test right?)

Any other options?

Thank you,

gcstang,
Sorry for the delay in getting to this and thanks for putting together an easy to run test case.

I ran your sample verbatim and the editor is showing the key (Websid) and Description (Dsc). See attached screenshot.

I then ran your sample against SmartGWT 1.1 and was able to reproduce the issue.

It must have been a bug in 1.1 which was subsequently fixed. Please get the latest build from SVN or here http://smartgwt.build.rorschach.de/latest/

Sanjiv

New Version works

Thank you, this build works.

Was this build based off of your trunk version or just a later version of 1.1?