SmartClient Version: v10.1p_2016-12-11/Enterprise Deployment (built 2016-12-11)
Chrome Version 64.0.3282.167
I have two objects, Contract and Pipeline. Each Contract has an attribute containing an integer key that references a Pipeline.
I have a ListGrid that displays rows of Contract data with a datasource xml defining the fields, and a separate Pipeline datasource xml because I have another grid elsewhere that shows Pipeline information. Both datasource xml files have operation bindings to Java files that interact with an Oracle SQL database. One of the columns of my Contract ListGrid shows the Pipeline key reference, but I want it to show the String name for the referenced Pipeline. After searching the forums and docs, I setup a foreignKey relationship on my Contract datasource field like so:
contract.ds.xml
pipeline.ds.xml
ContractGrid.java with some code and information redacted for privacy
Currently, when my Contract grid is populated with Contract data rows, the "Pipeline" column still shows the integer pipelineKey value, but if I double click on that field to edit it I get a SelectItem filled with Pipeline names (which is partially what I want). If I set the field to a different Pipeline, the Pipeline name will stay displayed in the field while that row indicates it has edits. Saving or refreshing the data causes the pipelineKey to be shown again. What I'd like is for the Pipeline names to be shown at all times, but the pipelineKey to be the value that is actually stored on the Contract object. Can anyone help me figure out what I need to do to always show the pipeline names, both when editing and when just displaying data?
Chrome Version 64.0.3282.167
I have two objects, Contract and Pipeline. Each Contract has an attribute containing an integer key that references a Pipeline.
I have a ListGrid that displays rows of Contract data with a datasource xml defining the fields, and a separate Pipeline datasource xml because I have another grid elsewhere that shows Pipeline information. Both datasource xml files have operation bindings to Java files that interact with an Oracle SQL database. One of the columns of my Contract ListGrid shows the Pipeline key reference, but I want it to show the String name for the referenced Pipeline. After searching the forums and docs, I setup a foreignKey relationship on my Contract datasource field like so:
contract.ds.xml
Code:
<DataSource ID="contract" allowAdvancedCriteria="true"> <fields> <field name="contractKey" title="Key" hidden="true" type="integer" primaryKey="true" required="true"/> <field name="name" title="Name (Full)" hidden="false" type="text" canEdit="true" width="10%"/> <field name="abbrev" title="Abbrev" hidden="false" type="text" canEdit="true" width="6%"/> <field name="contractRef" title="Contract Ref" hidden="false" type="text" canEdit="true" width="10%" cellAlign="center"/> <field name="description" title="Description" hidden="false" type="text" canEdit="true" width="10%"/> <field name="pipelineKey" title="Pipeline" hidden="false" type="integer" canEdit="true" width="10%" cellAlign="center" foreignKey="pipeline.pipelineKey" displayField="pipeline.name" valueField="pipelineKey"/> </fields> <operationBindings> <binding operationType="fetch" serverMethod="executeFetch"> <serverObject className="com.my.app.contracts.ContractDS"/> </binding> </operationBindings> </DataSource>
Code:
<DataSource ID="pipeline" allowAdvancedCriteria="true"> <fields> <field name="pipelineKey" hidden="true" title="Key" type="integer" primaryKey="true"/> <field name="name" hidden="false" title="Pipeline Name" type="text" width="20%" canEdit="true" required="true"/> <field name="description" hidden="false" title="Description" type="text" width="30%" canEdit="true"/> <field name="pipelineType" hidden="false" title="Type" type="text" width="10%" canEdit="true" required="true"/> </fields> <operationBindings> <binding operationType="fetch" serverMethod="executeFetch"> <serverObject className="com.my.app.pipeline.PipelineDS" /> </binding> </operationBindings> </DataSource>
Code:
public class ContractGrid extends ListGrid { public ContractGrid() { super(DataSource.get("contract")); this.setCanEdit(true); this.setDataFetchMode(FetchMode.LOCAL); this.setCriteria(place.getDateCriteria()); this.setWidth(100); this.setHeight(100); this.setDrawAheadRatio(4); this.setCanExpandRecords(true); this.setAutoFetchData(true); } }
Comment