]> git.proxmox.com Git - extjs.git/blame - extjs/examples/classic/app/nested-loading/app/view/review/List.js
add extjs 6.0.1 sources
[extjs.git] / extjs / examples / classic / app / nested-loading / app / view / review / List.js
CommitLineData
6527f429
DM
1/**\r
2 * A view which displays a list of reviews for a specified book.\r
3 * @extends Ext.view.View\r
4 */\r
5Ext.define('Books.view.review.List', {\r
6 alias: 'widget.reviewlist',\r
7 extend: 'Ext.panel.Panel',\r
8\r
9 requires: ['Ext.layout.container.Card'],\r
10\r
11 initComponent: function() {\r
12 this.dataview = Ext.create('Ext.view.View', {\r
13 id: 'reviews',\r
14 border: false,\r
15 cls: 'review-list',\r
16\r
17 scrollable: true,\r
18\r
19 itemSelector: '.review',\r
20 tpl: new Ext.XTemplate(\r
21 '<tpl for=".">',\r
22 '<div class="review {[xindex === 1 ? "first-review" : ""]}">',\r
23 '<div class="title">{title} {[this.stars(values)]}</div>',\r
24 '<div class="author">By <span>{author}</span> - {date}</div>',\r
25 '<div class="comment">{comment}</div>',\r
26 '</div>',\r
27 '</tpl>',\r
28 {\r
29 stars: function(values) {\r
30 var res = [],\r
31 extension = Ext.isIE6 ? 'gif' : 'png',\r
32 i = 0;\r
33\r
34 //print out the stars for each of the ratings\r
35 for (; i < values.rating; i++) {\r
36 res.push('<img src="./resources/images/star.', extension, '" />');\r
37 }\r
38\r
39 //print out transparent stars for the rest (up to 5)\r
40 while (i < 5) {\r
41 res.push('<img src="./resources/images/star_no.', extension, '" />');\r
42 i++;\r
43 }\r
44\r
45 return res.join('');\r
46 }\r
47 }\r
48 )\r
49 });\r
50\r
51 Ext.apply(this, {\r
52 border: false,\r
53 flex: 1,\r
54 id: 'test',\r
55\r
56 layout: 'card',\r
57\r
58 dockedItems: [\r
59 Ext.create('Books.view.Header', {\r
60 html: 'Reviews'\r
61 })\r
62 ],\r
63\r
64 items: this.dataview\r
65 });\r
66\r
67 this.callParent(arguments);\r
68 },\r
69\r
70 /**\r
71 * Used to bind a store to this dataview.\r
72 * Delegates to bindStore and also shows this view\r
73 * @param {Ext.data.Model} record The record to bind\r
74 * @param {Ext.data.Store} store The reviews store used by the application\r
75 */\r
76 bind: function(record, store) {\r
77 //put the reviews into the store and bind the store to thie dataview\r
78 this.dataview.bindStore(record.reviews());\r
79 }\r
80});\r