Upgrade to ExtJS 4.0.7 - Released 10/19/2011
[extjs.git] / examples / app / nested-loading / app / view / book / View.js
1 /*
2
3 This file is part of Ext JS 4
4
5 Copyright (c) 2011 Sencha Inc
6
7 Contact:  http://www.sencha.com/contact
8
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
11
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
13
14 */
15 /**
16  * The view which displays information about a speficied book
17  * @extends Ext.panel.Panel
18  */
19 Ext.define('Books.view.book.View', {
20     alias: 'widget.bookview',
21     extend: 'Ext.panel.Panel',
22     
23     initComponent: function() {
24         Ext.apply(this, {
25             id        : 'itemCt',
26             cls       : 'item-ct',
27             flex      : 2,
28             border    : false,
29             autoScroll: true,
30             
31             layout: {
32                 type : 'hbox',
33                 align: 'middle',
34                 pack : 'center'
35             },
36             
37             items: [
38                 {
39                     id    : 'imgCt',
40                     border: false,
41                     margin: '0 10 0 0',
42                     width : 250,
43                     height: 308
44                 },
45                 {
46                     id    : 'contentCt',
47                     width : 500,
48                     border: false
49                 }
50             ]
51         });
52                 
53         this.callParent(arguments);
54     },
55     
56     /**
57      * Binds a record to this view
58      */
59     bind: function(record) {
60         var imgCt = Ext.getCmp('imgCt'),
61             contentCt = Ext.getCmp('contentCt');
62         
63         var imgTpl = new Ext.XTemplate(
64             '<img src="{image}" />'
65         );
66         
67         var contentTpl = new Ext.XTemplate(
68             '<div class="name">{name} <span>${price}</span></div>',
69             '<div class="author">By {author}</div>',
70             '<div class="detail">{detail}</div>'
71         );
72         
73         imgTpl.overwrite(imgCt.el, record.data);
74         contentTpl.overwrite(contentCt.el, record.data);
75         
76         //update the layout of the contentTpl
77         contentCt.setHeight('auto');
78         this.doLayout();
79     }
80 });