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.
17 * Used to manage books; showing the first book, showing a spefied book, loading books, and showing their
20 Ext.define('Books.controller.Books', {
21 extend: 'Ext.app.Controller',
24 stores: ['Books', 'Reviews'],
27 {ref: 'bookSideBar', selector: 'booksidebar'},
28 {ref: 'bookView', selector: 'bookview'},
29 {ref: 'reviewList', selector: 'reviewlist'}
37 selectionchange: me.onSideBarSelectionChange
41 me.getBooksStore().on({
43 load : me.onBooksStoreLoad
47 onLaunch: function() {
48 this.getBookSideBar().bindStore(this.getBooksStore());
51 onSideBarSelectionChange: function(view, records) {
53 this.showBook(records[0]);
58 * Called when the books store is loaded.
59 * Checks if there are any records, and if there are, it delegates to show the first record
60 * as well as selecting that record in the sidebar
62 onBooksStoreLoad: function(store, records) {
63 Ext.defer(function() {
65 var record = records[0],
68 me.getBookSideBar().getSelectionModel().select(record);
74 * Shows a specified record by binding it to
76 showBook: function(record) {
79 me.getBookView().bind(record);
80 me.getReviewList().bind(record, me.getReviewsStore());