-
11 Feb 2009 8:33 PM #1
display XML in Grid
display XML in Grid
Hi
this is very frustrating, i've been trying for quite a while. I m trying to display a set of data in a Grid, the data is retrieved from a Servlet. What the Servlet does is to access the Database, find the object, and what i do here is to use Castor to convert the Java Object into XML, and transfer back to the client.
the original XML is like this:
I want to display this in a grid like:Code:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <xflow-location> <location> <document> <page> <datacell> <pk_datacell_id>1</pk_datacell_id> <last_updated>2009-02-10T11:21:28.000+11:00</last_updated> <datacell_name>Consignment</datacell_name> <datacell_value>SL140660</datacell_value> </datacell> <datacell> <pk_datacell_id>2</pk_datacell_id> <last_updated>2009-02-10T11:21:28.000+11:00</last_updated> <datacell_name>customer_ref</datacell_name> <datacell_value>948272</datacell_value> </datacell> <datacell> <pk_datacell_id>3</pk_datacell_id> <last_updated>2009-02-10T11:21:58.000+11:00</last_updated> <datacell_name>Job</datacell_name> <datacell_value>5454</datacell_value> </datacell> </page> <page> <datacell> <pk_datacell_id>4</pk_datacell_id> <last_updated>2009-02-10T11:21:58.000+11:00</last_updated> <datacell_name>Invoice_num</datacell_name> <datacell_value>94827223323</datacell_value> </datacell> </page> </document> </location> </xflow-location>
in the original XML, this info is contained in several rows, now i want to get them displayed within one row, datacell_name content text is the column name, and datacell_value content text is the column value, and rows are differentiated by the parent node, which is the document node(one Location will have lots of documents) in this case.Code:document id Consignment invoice num Job customer ref 1 SL140660 94827223323 5454 948272
can anyone help or even give me a bit hints, it will be sincerely appreciated!
Thank you!!!
Best regards
-
12 Feb 2009 1:33 AM #2
You have looked at the samples? There we have a Grid that gets populated using XML
-
12 Feb 2009 5:51 AM #3
Thanks for the reply.
I have looked at the samples, and tried the XML Grid. But in the sample, the grid are generated from a simple XML, which has only text contents, and no attributes, which are nomally what XML files contain.
And in my case, it's hard because each datacell within a document node needs to be displayed in the same row, but the XML structure determines that each datacell is a single row. Let's put it this way, each datacell has the same nodes, which are 'datacell-name' and 'datacell-value', in database, datacells are different table rows
i m not sure whether i make it clear or not, if you take a bit time to think about it u'll see what i meant. What i m doing now is using JAVA to convert the XML file into the structure that is used in the XML Grid sample, it now looks like this:
As we can see, that i put the PkId of the document a child Element of the Document element, If you could show me how to display the Attribute in a Grid, it'll be so great! e.g.Code:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <location pkid="2"> <document> <id>1</id> <Consignment>SL28350</Consignment> <Job>3984728</Job> </document> <document> <id>2</id> <Consignment>SL2222</Consignment> <Job>222222</Job> </document> </location>
---------------------------------------
<document pkid="1">
......
</document>
---------------------------------------
like in this XML, i want to display the PKID in the Grid.
Thanks!
-
13 Feb 2009 12:58 PM #4
As far as I know, and the GXT team should correct me if I'm wrong. But you'll need to remove the "pkid" attribute and create a "pkid" element in EACH "document" element. Your XML posted previously would then become this:
-JPCode:<?xml version="1.0" encoding="UTF-8" standalone="no"?> <location> <document> <pkid>2</pkid> <id>1</id> <Consignment>SL28350</Consignment> <Job>3984728</Job> </document> <document> <pkid>2</pkid> <id>2</id> <Consignment>SL2222</Consignment> <Job>222222</Job> </document> </location>
-
15 Feb 2009 1:22 AM #5
Thanks jpnet, it doesn't seem that EXT GWT has much flexibility in handling XML, i might have to convert the XML to satisfy what EXT GWT needs before feeding in.


Reply With Quote