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