In this section, you will learn to use XML in addition to the Gridpanel data source with JSON
One. static example
1.xml file content:
<?xml version= "1.0" encoding= "UTF-8"?>
<Data>
<Items>
<TotalResults>203</TotalResults>
<TotalPages>21</TotalPages>
<Item>
<ASIN>0446355453</ASIN>
<Author>Jimmy.Yang</Author>
<manufacturer>warner books</manufacturer>
<ProductGroup>Book</ProductGroup>
<title>master of the Game</title>
</Item>
<Item>
<ASIN>0446613657</ASIN>
<author>sidney sheldon</author>
<manufacturer>warner books</manufacturer>
<ProductGroup>Book</ProductGroup>
<title>are you afraid of the dark?</title>
</Item>
</Items>
</Data>
2.ExtJs Call Page
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<link rel= "stylesheet" type= text/css "href=". /resources/css/ext-all.css "/>
<script type= "Text/javascript" src= ". /adapter/ext/ext-base.js "></script>
<script type= "Text/javascript" src= ". /ext-all.js "></script>
<title>ExtJs_Grid_Xml</title>
<body>
<script type= "Text/javascript" >
Ext.onready (function () {
var store = new Ext.data.Store ({
URL: ' Griddata.xml ',
Reader:new Ext.data.XmlReader (
{record: ' Item '},
["ASIN", "Author", "Manufacturer", "ProductGroup", "Title"])
});
var Grid = new Ext.grid.GridPanel ({
Store:store,
Columns: [
{ID: "ASIN", Header: "Publishing Number", width:120, Dataindex: ' ASIN ', sortable:true},
{header: "Author", width:120, Dataindex: ' Author ', sortable:true},
{header: "title", width:180, Dataindex: ' title ', Sortable:true},
{header: "producer", width:115, Dataindex: ' Manufacturer ', sortable:false},
{header: "product group", width:100, Dataindex: ' ProductGroup ', sortable:false}],
Renderto: ' Example-grid ',
Viewconfig: {columnstext: ' Display Columns ', Sortasctext: ' Ascending ', Sortdesctext: ' Descending '},
width:640,
height:100
});
Store.load ();
});
</script>
<div id= "Example-grid" ></div>
</body>
The results of the operation are shown below:
Reprint please specify from "Yang under the Banyan Tree" http://www.cnblogs.com/yjmyzz/archive/2008/08/28/1278949.html