/*
 * Ext JS Library 2.2.1
 * Copyright(c) 2006-2009, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.onReady(function(){

    // create the Data Store
    var store = new Ext.data.Store({
        // load using HTTP
        url: 'agent_dir.xml',

        // the return will be XML, so lets set up a reader
        reader: new Ext.data.XmlReader({
               // records will have an "Item" tag
               record: 'Agent',
               id: 'ASIN',
               totalRecords: '@total'
           }, [
               // set up the fields mapping into the xml doc
               // The first needs mapping, the others are very basic
               {name: 'Name', mapping: 'Name'},
               'Company', 'Phone', 'Email'
           ])
    });

    // create the grid
    var grid = new Ext.grid.GridPanel({
        store: store,
        columns: [
            {header: "Name", width: 150, dataIndex: 'Name', sortable: true},
            {header: "Company", width: 150, dataIndex: 'Company', sortable: true},
            {header: "Phone", width: 90, dataIndex: 'Phone', sortable: true},
            {header: "Email", width: 78, dataIndex: 'Email', sortable: true}
        ],
        renderTo:'example-grid',
        width: 488,
        height: 1500
    });

    store.load();
});

