3 <title>Debug Console</title>
\r
4 <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
\r
5 <link rel="stylesheet" type="text/css" href="../../resources/css/debug.css" />
\r
9 <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
\r
12 <script type="text/javascript" src="../../ext-all.js"></script>
\r
13 <script type="text/javascript" src="../../src/debug.js"></script>
\r
15 <style type="text/css">
\r
17 font:normal 12px verdana;
\r
28 background-image:url(../shared/icons/fam/folder_wrench.png);
\r
31 background-image:url(../shared/icons/fam/folder_go.png);
\r
34 <script type="text/javascript">
\r
35 Ext.onReady(function(){
\r
37 Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
\r
41 App.BookStore = function(config) {
\r
42 var config = config || {};
\r
43 Ext.applyIf(config, {
\r
44 reader: new Ext.data.XmlReader({
\r
45 // records will have an "Item" tag
\r
48 totalRecords: '@total'
\r
50 // set up the fields mapping into the xml doc
\r
51 // The first needs mapping, the others are very basic
\r
52 {name: 'Author', mapping: 'ItemAttributes > Author'},
\r
56 // Detail URL is not part of the column model of the grid
\r
60 // call the superclass's constructor
\r
61 App.BookStore.superclass.constructor.call(this, config);
\r
63 Ext.extend(App.BookStore, Ext.data.Store);
\r
67 App.BookGrid = Ext.extend(Ext.grid.GridPanel, {
\r
69 initComponent : function() {
\r
71 // Pass in a column model definition
\r
72 // Note that the DetailPageURL was defined in the record definition but is not used
\r
73 // here. That is okay.
\r
75 {header: "Author", width: 120, dataIndex: 'Author', sortable: true},
\r
76 {header: "Title", dataIndex: 'Title', sortable: true},
\r
77 {header: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true},
\r
78 {header: "Product Group", dataIndex: 'ProductGroup', sortable: true}
\r
80 sm: new Ext.grid.RowSelectionModel({singleSelect: true}),
\r
81 // Note the use of a storeId, this will register thisStore
\r
82 // with the StoreMgr and allow us to retrieve it very easily.
\r
83 store: new App.BookStore({
\r
84 storeId: 'gridBookStore',
\r
87 // force the grid to fit the space which is available
\r
92 // finally call the superclasses implementation
\r
93 App.BookGrid.superclass.initComponent.call(this);
\r
96 Ext.reg('bookgrid', App.BookGrid);
\r
101 * @extends Ext.Panel
\r
102 * This is a specialized Panel which is used to show information about
\r
105 * This demonstrates adding 2 custom properties (tplMarkup and
\r
106 * startingMarkup) to the class. It also overrides the initComponent
\r
107 * method and adds a new method called updateDetail.
\r
109 * The class will be registered with an xtype of 'bookdetail'
\r
111 App.BookDetail = Ext.extend(Ext.Panel, {
\r
112 // add tplMarkup as a new property
\r
114 'Title: <a href="{DetailPageURL}" target="_blank">{Title}</a><br/>',
\r
115 'Author: {Author}<br/>',
\r
116 'Manufacturer: {Manufacturer}<br/>',
\r
117 'Product Group: {ProductGroup}<br/>'
\r
119 // startingMarup as a new property
\r
120 startingMarkup: 'Please select a book to see additional details',
\r
121 // override initComponent to create and compile the template
\r
122 // apply styles to the body of the panel and initialize
\r
123 // html to startingMarkup
\r
124 initComponent: function() {
\r
125 this.tpl = new Ext.Template(this.tplMarkup);
\r
128 background: '#ffffff',
\r
131 html: this.startingMarkup
\r
133 // call the superclass's initComponent implementation
\r
134 App.BookDetail.superclass.initComponent.call(this);
\r
136 // add a method which updates the details
\r
137 updateDetail: function(data) {
\r
138 this.tpl.overwrite(this.body, data);
\r
141 // register the App.BookDetail class with an xtype of bookdetail
\r
142 Ext.reg('bookdetail', App.BookDetail);
\r
146 * App.BookMasterDetail
\r
147 * @extends Ext.Panel
\r
149 * This is a specialized panel which is composed of both a bookgrid
\r
150 * and a bookdetail panel. It provides the glue between the two
\r
151 * components to allow them to communicate. You could consider this
\r
152 * the actual application.
\r
155 App.BookMasterDetail = Ext.extend(Ext.Panel, {
\r
156 // override initComponent
\r
157 initComponent: function() {
\r
158 // used applyIf rather than apply so user could
\r
159 // override the defaults
\r
160 Ext.applyIf(this, {
\r
162 title: 'Book List',
\r
168 itemId: 'gridPanel',
\r
173 xtype: 'bookdetail',
\r
174 itemId: 'detailPanel',
\r
178 // call the superclass's initComponent implementation
\r
179 App.BookMasterDetail.superclass.initComponent.call(this);
\r
181 // override initEvents
\r
182 initEvents: function() {
\r
183 // call the superclass's initEvents implementation
\r
184 App.BookMasterDetail.superclass.initEvents.call(this);
\r
186 // now add application specific events
\r
187 // notice we use the selectionmodel's rowselect event rather
\r
188 // than a click event from the grid to provide key navigation
\r
189 // as well as mouse navigation
\r
190 var bookGridSm = this.getComponent('gridPanel').getSelectionModel();
\r
191 bookGridSm.on('rowselect', this.onRowSelect, this);
\r
193 // add a method called onRowSelect
\r
194 // This matches the method signature as defined by the 'rowselect'
\r
195 // event defined in Ext.grid.RowSelectionModel
\r
196 onRowSelect: function(sm, rowIdx, r) {
\r
197 // getComponent will retrieve itemId's or id's. Note that itemId's
\r
198 // are scoped locally to this instance of a component to avoid
\r
199 // conflicts with the ComponentMgr
\r
200 var detailPanel = this.getComponent('detailPanel');
\r
201 detailPanel.updateDetail(r.data);
\r
204 // register an xtype with this class
\r
205 Ext.reg('bookmasterdetail', App.BookMasterDetail);
\r
208 // Finally now that we've defined all of our classes we can instantiate
\r
209 // an instance of the app and renderTo an existing div called 'binding-example'
\r
210 // Note now that classes have encapsulated this behavior we can easily create
\r
211 // an instance of this app to be used in many different contexts, you could
\r
212 // easily place this application in an Ext.Window for example
\r
213 // create an instance of the app
\r
214 var bookApp = new App.BookMasterDetail({
\r
215 renderTo: 'center2'
\r
217 // We can retrieve a reference to the data store
\r
218 // via the StoreMgr by its storeId
\r
219 Ext.StoreMgr.get('gridBookStore').load();
\r
224 var viewport = new Ext.Viewport({
\r
225 id: 'viewport-component',
\r
228 new Ext.BoxComponent({ // raw
\r
236 contentEl: 'south',
\r
247 title: 'East Side',
\r
259 tabPosition:'bottom',
\r
261 html:'<p>A TabPanel component can be a region.</p>',
\r
265 new Ext.grid.PropertyGrid({
\r
267 title: 'Property Grid',
\r
270 "(name)": "Properties Grid",
\r
272 "autoFitColumns": true,
\r
273 "productionQuality": false,
\r
274 "created": new Date(Date.parse('10/15/2006')),
\r
291 layout:'accordion',
\r
298 title:'Navigation',
\r
302 id:'west-settings',
\r
304 html:'<p>Some settings in here.</p>',
\r
310 id:'center-region',
\r
312 deferredRender:false,
\r
316 contentEl:'center1',
\r
322 contentEl:'center2',
\r
323 title: 'Center Panel',
\r
333 <script type="text/javascript" src="../shared/examples.js"></script><!-- EXAMPLES -->
\r
335 <p>Hi. I'm the west panel.</p>
\r
338 <p>north - generally for menus, toolbars and/or advertisements</p>
\r
343 <p>Included in ext-all-debug.js is the Ext Debug Console. It offers a limited amount of <a href="http://getfirebug.com">FireBug</a>
\r
344 functionality cross browser. The most important feature is the "DOM Inspector" and CSS and DOM attribute editing. In any browser where "console"
\r
345 is not already defined, the Ext console will handle console.log(), time() and other calls.
\r
349 This page includes ext-all-debug.js and some test markup so you can try it out. Click on the image below to bring up the console.
\r
351 <a href="#" onclick="Ext.log('Hello from the Ext console. This is logged using the Ext.log function.');return false;"><img src="debug.png" style="margin:15px;"/></a>
\r
354 The full source is available in the "source" directory of the Ext download.
\r
357 <div id="props-panel" style="width:200px;height:200px;overflow:hidden;">
\r
360 <p>south - generally for informational stuff, also could be for status bar</p>
\r