-
13 Apr 2007 11:26 AM #1
Nested View Objects/Nested Xml collections
Nested View Objects/Nested Xml collections
2 questions in one,
Can you use the xmlReader to read something that looks like this:
So that it would returnCode:<items> <item> <title>my title</title> <description>This would be a description</description> <tags> <tag> <name>first</name> <name>second</name> <name>third</name> </tag> </tags> </item> <item> <title>my title</title> <description>This would be a description</description> <tags> <tag> <name>first</name> <name>second</name> <name>third</name> </tag> </tags> </item> </items>
record.data.title => 'my title'
and
record.data.tags[0].name => "first"
second part to the question is: can you nest views/templates?
BTW, I am using the 1.0 b2 version
-
13 Apr 2007 12:24 PM #2
1. Look at xml-grid example. You can do xpath type field mapping.
2. Not sure what you're looking for with nesting. You might look at the MasterTemplate classTim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
13 Apr 2007 2:34 PM #3
are you saying that if I do something like this
This will automatically group those tag/names values under a single record?Code:var dsr = new Ext.data.XmlReader({ record: 'item', },[ {title: 'title', description: 'description', tagName: 'name', mapping: 'item > tag'} ] });
I am trying to get those nested values as an array of elements for the item parent.
So that when I select one of them I can tell how many and which tag.name are associated with it.
record.data.tags[0].name #=> first
I am looking to create a nested grid or nested view.
-
13 Apr 2007 3:46 PM #4
No I meant you could navigate down to deeper single attributes/elements. There's no 'grouping' functionality.
Tim Ryan
Read BEFORE posting a question / BEFORE posting a Bug
Use Google to Search - API / Forum
API Doc (4.x | 3.x | 2.x | 1.x) / FAQ / 1.x->2.x Migration Guide / 2.x->3.x Migration Guide
-
16 Apr 2007 9:08 AM #5
Well then
I guess I am going to vote it as a feature request.
Has anybody requested it before me?
-
17 Apr 2007 12:06 AM #6
You can do it with the latest JsonReader.
Json data block:
Code:{ items: [ {title: "my title", description:"my desc", name: ["firstName", "secondName", "third name"]} ],The JsonReader creates dynamic accessor functions into which it passes the row object as the parameter "obj". It uses the expressionCode:var dsr = new Ext.data.XmlReader({ record: 'item', }, [ {title: 'title', description: 'description', tagName: 'name', mapping: 'name[0] + " " + obj.name[1] + " " + obj.name[2]'} ] });
to create the function source code to extract the data, so you can use that to create complex accessors.Code:"obj." + mappingExpression
-
13 Sep 2007 12:44 PM #7
Nested XML question
Nested XML question
Hi,
I have a similar situation to create mapping for nested xml data using XMLReader, I need to read nested xml data.
sample xml is as below....
<ComponentVO>
<id>112</id>
<name>Java</name>
<version>1.6</version>
<commercialComponent>true</commercialComponent>
<openSourceComponent>true</openSourceComponent>
<containsCrypto>false</containsCrypto>
<textsOfLicences>
<TextOfLicenseVO>
<id>113</id>
<text>License Information 2</text>
</TextOfLicenseVO>
<TextOfLicenseVO>
<id>114</id>
<text>License Information 1</text>
</TextOfLicenseVO>
</textsOfLicences>
<description>Java 1.6 description</description>
<notes/>
</ComponentVO>
Iam not sure about creating a mapping for TextofLicenseVO.
Here is the store definition
var comp_data = new Ext.data.Store({
// load using HTTP
proxy: new Ext.data.HttpProxy({url: '/myapp/ComponentServiceServlet?action=load&cid=' + selprodId}),
reader: new Ext.data.XmlReader({
record: '',
id: 'id'
},[
{name: 'id'},'name','version','release','supplier','description',
'commercialComponent','openSourceComponent','containsCrypto',
{name: 'licenseText', mapping:'TextOfLicenseVO > text'}
])
});
licenseText gives me only the last instance. How to give the mapping for TextOfLicenseVO so that i can access all the values under this tag.
Thanks
-navamara
-
2 Oct 2007 5:20 AM #8
I need this functionality for XMLReader in ExtJS1.1.1
How can I map nested elements to one record?
I tried mappings like:
{name: 'mydata', mapping: 'type//*@data'}
{name: 'mydata', mapping: 'type/*@data'}
{name: 'mydata', mapping: 'type/nested*@data'}
{name: 'mydata', mapping: 'type/nested@data'} // only first element is read... :-(
XML:
<root>
<record> <-- this is my record: 'record' in XMLReader (top mappings (mydata) are relative to this element)
<type name="A">
<nested data="A" />
<nested data="B" />
</type>
</record>
</root>
Thanks...
edit: also tried mapping "//@data" or '//nested[@data]' which should get any data attribute element, doesn't matter where it is, but still my store won't add all data to its record. I think the data store isn't clever enough to pull the data into the record as an array or sth. like that. (Is this correct, and when not how can I tell the grid to use also the array data e.g.).
Anyone has any idea / tip how to solve this?Last edited by Iveco; 2 Oct 2007 at 6:49 AM. Reason: more information
-
2 Oct 2007 10:05 AM #9
I solved this by using a second datastore which is using the root element id: <name> so I can loop the multiply elements and I use store.filterBy(myfunction) to only get the wished values for my detail grid.
If anyone has an idea to how to solve this with one datastore would be great.
-
11 Oct 2007 6:49 AM #10
Hi Iveco,
Could you please post your 2 store solution?
Thanks,
--Bill


Reply With Quote