3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">Ext.onReady(function(){
10 // create the Data Store
11 var store = new Ext.data.Store({
15 // the return will be XML, so lets set up a reader
16 reader: new Ext.data.XmlReader({
17 // records will have an "Item" tag
20 totalRecords: '@total'
22 // set up the fields mapping into the xml doc
23 // The first needs mapping, the others are very basic
24 {name: 'Author', mapping: 'ItemAttributes > Author'},
28 // Detail URL is not part of the column model of the grid
34 var grid = new Ext.grid.GridPanel({
37 {header: "Author", width: 120, dataIndex: 'Author', sortable: true},
38 {header: "Title", width: 180, dataIndex: 'Title', sortable: true},
39 {header: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true},
40 {header: "Product Group", width: 100, dataIndex: 'ProductGroup', sortable: true}
42 sm: new Ext.grid.RowSelectionModel({singleSelect: true}),
51 // define a template to use for the detail view
53 'Title: <a href="{DetailPageURL}" target="_blank">{Title}</a><br/>',
54 'Author: {Author}<br/>',
55 'Manufacturer: {Manufacturer}<br/>',
56 'Product Group: {ProductGroup}<br/>'
58 var bookTpl = new Ext.Template(bookTplMarkup);
60 var ct = new Ext.Panel({
61 renderTo: 'binding-example',
73 background: '#ffffff',
76 html: 'Please select a book to see additional details.'
80 grid.getSelectionModel().on('rowselect', function(sm, rowIdx, r) {
81 var detailPanel = Ext.getCmp('detailPanel');
82 bookTpl.overwrite(detailPanel.body, r.data);