datasource xml

Hi,

I am unable to find information on creating an xml schema for datasources. How can I map a many to one relationship between two datasource xml’s and what other attibutes are available on a xml field. (Is there an xml template for the sql connector?)

Thanks

The full docs on all properties are here.

These samples show two styles of working with nested objects:

  1. treat subobjects as just data fields of the parent object, always loaded/saved with the parent object, shown here.

  2. treat them as separate entities with independent IDs related by foreignKey, with separate load/save operations, shown here.

field mapping

Hi,

Thanks for the quick reply. I am trying to follow option 1 but am missing how to tell Smartgwt what the foreign key is.

PARENT DATASOURCE

<DataSource ID=“Locations” dataFormat=“iscServer” serverType=“sql” tableName=“Locations”>
<fields>
<field title=“ID” name=“LocationId” type=“text” length=“5” primaryKey=“true”/>
<field name=“LocationName” type=“text” length=“64”/>
<field name=“LocationCourseTypes” multiple=“true” type=“LocationCourseTypes”/>
</fields>
<dataSourceVersion>1</dataSourceVersion>
<generatedBy>SC_SNAPSHOT-2010-03-09/Enterprise Deployment 2010-03-09</generatedBy>
</DataSource>

CHILD DATASOURCE (has a composite key, locationID is a foriegn key to Locations)

<DataSource ID=“LocationCourseTypes” dataFormat=“iscServer” serverType=“sql” tableName=“LocationCourseTypes”>
<fields>
<field name=“LocationID” type=“text” length=“5” primaryKey=“true”/>
<field name=“CourseTypeID” type=“text” length=“10” primaryKey=“true”/>
</fields>
<dataSourceVersion>1</dataSourceVersion>
<generatedBy>SC_SNAPSHOT-2010-03-09/Enterprise Deployment 2010-03-09</generatedBy>
</DataSource>

Thanks.

You probably want to use option #2 with SQL. There is not currently support for automatically populating a nested structure with SQL tables, or doing the appropriate series of adds, removes and deletes on save of a nested structure. You can do it yourself of course, but it’s probably simpler to just treat the objects independently.

If you’re trying to do something like populate a table with related records from the child DataSource, see ListGrid.fetchRelatedData() and see also the SQL templating examples (such as Large Value Map) to see how to do joins.