1. #1
    Ext User
    Join Date
    Mar 2008
    Posts
    1
    Vote Rating
    0
    joji_khan is on a distinguished road

      0  

    Thumbs up Populate grid from Inline XML (XmlReader)

    Populate grid from Inline XML (XmlReader)


    After a bit of struggle i am able to use inline xml. Here is my two cents. Thanks for the_bagbournes for his help.

    Code:
    /*
    * Ext JS Library 2.0.2
    * Copyright(c) 2006-2008, Ext JS, LLC.
    * licensing@extjs.com
    * 
    * http://extjs.com/license
    */
    Ext.onReady(function(){
    var xmlstr = "<Items>"+
    "<TotalResults>203</TotalResults>"+
    "<TotalPages>21</TotalPages>"+
    "<Item>"+
    "<ASIN>0446355453</ASIN>"+
    "<ItemAttributes>"+
    "<Author>Sidney Sheldon</Author>"+
    "<Manufacturer>Warner Books</Manufacturer>"+
    "<ProductGroup>Book</ProductGroup>"+
    "<Title>Master of the Game</Title>"+
    "</ItemAttributes>"+
    "</Item>"+
    "<Item>"+
    "<ASIN>0446613657</ASIN>"+
    "<ItemAttributes>"+
    "<Author>Sidney Sheldon</Author>"+
    "<Manufacturer>Warner Books</Manufacturer>"+
    "<ProductGroup>Book</ProductGroup>"+
    "<Title>Are You Afraid of the Dark?</Title>"+
    "</ItemAttributes>"+
    "</Item>"+
    "</Items>";
    var doc;
    
    if (window.ActiveXObject) {
    var doc = new ActiveXObject("Microsoft.XMLDOM");
    doc.async = "false";
    doc.loadXML(xmlstr);
    } 
    else {
    var doc = new DOMParser().parseFromString(xmlstr,"text/xml");
    }
    var xmlReader = new Ext.data.XmlReader({
    // records will have an "Item" tag
    record: 'Item',
    id: 'ASIN',
    totalRecords: '@total'
    }, [
    // set up the fields mapping into the xml doc
    // The first needs mapping, the others are very basic
    {name: 'Author', mapping: 'ItemAttributes > Author'},
    'Title', 'Manufacturer', 'ProductGroup'
    ]);
    var store = new Ext.data.Store({
    
    proxy: new Ext.data.MemoryProxy(doc),
    reader: xmlReader
    
    });
    
    var grid = new Ext.grid.GridPanel({
    store: store,
    columns: [
    {header: "Author", width: 120, dataIndex: 'Author', sortable: true},
    {header: "Title", width: 180, dataIndex: 'Title', sortable: true},
    {header: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true},
    {header: "Product Group", width: 100, dataIndex: 'ProductGroup', sortable: true}
    ],
    renderTo:'example-grid',
    width:540,
    height:200
    });
    store.load();
    });
    
    Jaweed sarfraz
    Attached Files
    Last edited by joji_khan; 12 Mar 2008 at 2:18 PM. Reason: Attachment Added

  2. #2
    Ext User
    Join Date
    Apr 2008
    Posts
    83
    Vote Rating
    0
    ludhiana is on a distinguished road

      0  

    Default dynamic xml

    dynamic xml


    Hi,
    Can you please tell me how to use dynamic xml with this code. I am getting dynamic xml with java servlet but do not know how to make an object of it. I want to create doc with my dynamic xml as you are creating in your example.
    CODE]proxy: new Ext.data.MemoryProxy(doc)[[/CODE]
    and I want ot make a string of my dynamic xml.

    var xmlstr = dynamic xml
    but I really do not know how to make a string of my xml. My xml has 500 records. I display xml with
    'http://localhost:8080/fastcarfm/servive/new/' url
    <items>
    <part><a = "1"></a><b = "2"></b></part>
    <part><d = "1"></d><b = "2"></b></part>
    <part><c = "1"></c><n = "2"></n></part>
    <part><g = "1"></g><m = "2"></m></part>
    .....
    </items>

    I want to display this xml in a grid with paging memory proxy.
    Please help.

Thread Participants: 1

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..." hd porno faketaxi