I've setup ListGrid objects that use a DataSource and they work great with the ForeignKey setup, however when I try to use the same DataSource in a DynamicForm the drop down for the ForeignKeys only show the value field not the display field.
ListGridWidget (code)
Example Datasource Field (code (small snippet example with one field))
Example SelectItem (code)
Form (using the same CategoryListGridDataSource above)
ListGridWidget (code)
Code:
public CategoryListGridWidget(Criteria c) { setCanEdit(true); setAutoSaveEdits(false); setShowFilterEditor(true); setDataSource(new CategoryListGridDS()); setAutoFetchData(true); setAlternateRecordStyles(true); setShowAllRecords(false); setDataPageSize(10); if(c != null) { setInitialCriteria(c); } setWrapCells(true); }
Code:
public CategoryListGridDS() { ... intField = new DataSourceIntegerField("cgytyp"); intField.setEditorType(new CategoryTypeSelectItem(time)); name = "categorytypeds_"+time; intField.setForeignKey(name+".cgytyp"); intField.setCanEdit(true); addField(intField); ... }
Code:
public CategoryTypeSelectItem(long id) { CategoryTypeListGridDS ds = new CategoryTypeListGridDS(); ds.setID("categorytypeds_"+id); setValueField("cgytyp"); setDisplayField("dsc"); setEmptyPickListMessage("No data in table"); setPickListWidth(450); ListGridField idField = new ListGridField("cgytyp"); ListGridField dscField = new ListGridField("dsc"); setPickListFields(idField, dscField); setOptionDataSource(ds); setAutoFetchData(true); }
Form (using the same CategoryListGridDataSource above)
Code:
CategoryListGridDS cglds = new CategoryListGridDS(); final DynamicForm df = new DynamicForm(); if(c != null) { df.setInitialCriteria(c); } df.setDataSource(cglds); df.setAutoFetchData(true);
Comment