1. #1
    Ext User
    Join Date
    Feb 2009
    Posts
    29
    Vote Rating
    0
    daeo is on a distinguished road

      0  

    Default 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:
    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>
    I want to display this in a grid like:

    Code:
    document id        Consignment              invoice num            Job            customer ref
    1                  SL140660                  94827223323          5454          948272
    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.

    can anyone help or even give me a bit hints, it will be sincerely appreciated!

    Thank you!!!

    Best regards

  2. #2
    Software Architect
    Join Date
    Sep 2007
    Posts
    13,971
    Vote Rating
    132
    sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light sven is a glorious beacon of light

      0  

    Default


    You have looked at the samples? There we have a Grid that gets populated using XML

  3. #3
    Ext User
    Join Date
    Feb 2009
    Posts
    29
    Vote Rating
    0
    daeo is on a distinguished road

      0  

    Default


    Quote Originally Posted by sven View Post
    You have looked at the samples? There we have a Grid that gets populated using XML
    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:
    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>
    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.
    ---------------------------------------
    <document pkid="1">
    ......
    </document>
    ---------------------------------------

    like in this XML, i want to display the PKID in the Grid.



    Thanks!

  4. #4
    Ext User
    Join Date
    Apr 2008
    Location
    Lincoln, NE
    Posts
    235
    Vote Rating
    0
    jpnet is an unknown quantity at this point

      0  

    Default


    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:

    Code:
    <?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>
    -JP

  5. #5
    Ext User
    Join Date
    Feb 2009
    Posts
    29
    Vote Rating
    0
    daeo is on a distinguished road

      0  

    Default


    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.

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."