3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
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.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * A view which displays a list of reviews for a specified book.
17 * @extends Ext.view.View
19 Ext.define('Books.view.review.List', {
20 alias: 'widget.reviewlist',
21 extend: 'Ext.panel.Panel',
23 requires: ['Ext.layout.container.Card'],
25 initComponent: function() {
26 this.dataview = Ext.create('Ext.view.View', {
33 store: 'Books.store.Review',
34 itemSelector: '.review',
35 tpl: new Ext.XTemplate(
37 '<div class="review {[xindex === 1 ? "first-review" : ""]}">',
38 '<div class="title">{title} {[this.stars(values)]}</div>',
39 '<div class="author">By <span>{author}</span> - {date}</div>',
40 '<div class="comment">{comment}</div>',
44 stars: function(values) {
47 //print out the stars for each of the ratings
48 for (var i = 0; i < values.rating; i++) {
49 res += '<img src="./resources/images/star.' + ((Ext.isIE6) ? 'gif' : 'png') + '" />';
52 //print out transparent stars for the rest (up to 5)
54 res += '<img src="./resources/images/star_no.' + ((Ext.isIE6) ? 'gif' : 'png') + '" />';
72 Ext.create('Books.view.Header', {
79 Ext.create('widget.panel', {
86 this.callParent(arguments);
90 * Used to bind a store to this dataview.
91 * Delegates to bindStore and also shows this view
92 * @param {Ext.data.Model} record The record to bind
93 * @param {Ext.data.Store} store The reviews store used by the application
95 bind: function(record, store) {
96 //put the reviews into the store and bind the store to thie dataview
97 store.loadData(record.data.reviews || []);
98 this.dataview.bindStore(store);