Hi,
I've been racking my head over this all weekend so I need some help from Isomorphic. I've looked at your samples and discussions and I can't find a single example of actually using an XML datasource that contains 1 record and contains a nested structure (built from XSDs) without having any primary key/foreign key relations.
There's lots in the documentation about how SmartClient builds the DataSources but I've struggled to find any documentation on how to use it.
- SmartClient version - 8.0 nightly from last week.
- No server-side problems
- No client-side errors
First my use-case: I have one XML document that is described by an XSD and it contains a list of ComplexTypes. The XML document is locked to the user and the user can and will only be able to ever look at that one document in the UI. I write the XML document out into a page variable and want the user to be able to manipulate it and then I want to be able to post back the updated XML to the server.
I have produced a superficial test case: My root document is of the type Author and nested type is Book:
XSD:
Some valid example XML:
My JS code:
In the above code the DynamicForm is populated just fine and the ListGrid shows the correct columns but no data.
When I have one Xml document (which seems to map to one record in a Data Source), how do I set things up so I can display a nested structure in a ListGrid?
Note: The code in schemaLoaded is the result of trying lots of permutations to get this working. I know it shouldn't work (since '.books' contains the type 'ArrayOfBook') but I don't know how to make it work.
I've been racking my head over this all weekend so I need some help from Isomorphic. I've looked at your samples and discussions and I can't find a single example of actually using an XML datasource that contains 1 record and contains a nested structure (built from XSDs) without having any primary key/foreign key relations.
There's lots in the documentation about how SmartClient builds the DataSources but I've struggled to find any documentation on how to use it.
- SmartClient version - 8.0 nightly from last week.
- No server-side problems
- No client-side errors
First my use-case: I have one XML document that is described by an XSD and it contains a list of ComplexTypes. The XML document is locked to the user and the user can and will only be able to ever look at that one document in the UI. I write the XML document out into a page variable and want the user to be able to manipulate it and then I want to be able to post back the updated XML to the server.
I have produced a superficial test case: My root document is of the type Author and nested type is Book:
XSD:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://localhost:19086/schema/" targetNamespace="http://localhost:19086/schema/" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="Author">
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1" nillable="true" />
<xs:element name="telephoneNumber" type="xs:string" minOccurs="0" maxOccurs="1" nillable="true" />
<xs:element name="dateOfBirth" type="xs:dateTime" minOccurs="0" maxOccurs="1" nillable="true" />
<xs:element name="lastRoyalty" type="xs:double" minOccurs="0" maxOccurs="1" nillable="true" />
<xs:element name="books" type="tns:ArrayOfBook" minOccurs="0" maxOccurs="1" nillable="true" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="Book">
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="0" maxOccurs="1" nillable="true" />
<xs:element name="isbn" type="xs:string" minOccurs="0" maxOccurs="1" nillable="true" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="ArrayOfBook">
<xs:sequence>
<xs:element name="Book" type="tns:Book" minOccurs="0" maxOccurs="unbounded" nillable="true" />
</xs:sequence>
</xs:complexType>
<xs:element name="Author" type="tns:Author" />
</xs:schema>
Some valid example XML:
Code:
<Author xmlns="http://localhost:19086/schema/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<name>A Jones</name>
<telephoneNumber>0208 123 4321</telephoneNumber>
<dateOfBirth>2011-01-31T13:56:27+00:00</dateOfBirth>
<lastRoyalty>2531.12</lastRoyalty>
<books>
<Book>
<name>Another Reality</name>
<isbn>010332X</isbn>
</Book>
<Book>
<name>First Sight</name>
<isbn>928421Z</isbn>
</Book>
</books>
</Author>
Code:
isc.DynamicForm.create({
ID: "dfAuthor"
, useAllDataSourceFields: true
, position: "relative"
, showComplexFields: false
, autoDraw: false
});
isc.ListGrid.create({
ID: "lgBook"
, useAllDataSourceFields: true
, position: "relative"
, autoDraw: false
});
var localData = {};
localData.author = "<Author xmlns=\"http://localhost:19086/schema/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><name>A Jones</name><telephoneNumber>0208 123 4321</telephoneNumber><dateOfBirth>2011-01-31T11:21:45+00:00</dateOfBirth><lastRoyalty>2531.12</lastRoyalty><books><Book><name>Another Reality</name><isbn>010332X</isbn></Book></books></Author>";
isc.XMLTools.loadXMLSchema('/webapi/ViewSchema.jsp?type=Author&version=2064.c53ee320-f8c2-4217-bace-7aa84478aea8T', schemaLoaded, {}, true);
function schemaLoaded(schemaSet) {
var xmlDoc = isc.xml.parseXML(localData.author);
var set = isc.SchemaSet.get('http://localhost:19086/schema/');
var ds = isc.DataSource.get('Author');
ds.setCacheAllData(true);
var records = ds.recordsFromXML(new Array(xmlDoc));
ds.setCacheData(records);
dfAuthor.setDataSource(ds);
dfAuthor.fetchData();
dfAuthor.draw();
// Help me here
var dsBook = isc.DataSource.get('Book');
lgBook.setDataSource(dsBook);
lgBook.setData(records[0].books);
lgBook.draw();
}
When I have one Xml document (which seems to map to one record in a Data Source), how do I set things up so I can display a nested structure in a ListGrid?
Note: The code in schemaLoaded is the result of trying lots of permutations to get this working. I know it shouldn't work (since '.books' contains the type 'ArrayOfBook') but I don't know how to make it work.
Comment