ExtJS Learning Notes (3) _gridpanel[xml do the data source]

Source: Internet
Author: User
Tags asin

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.