You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

364 lines
12 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <html>
  2. <head>
  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" />
  6. <!-- GC -->
  7. <!-- LIBS -->
  8. <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
  9. <!-- ENDLIBS -->
  10. <script type="text/javascript" src="../../ext-all.js"></script>
  11. <script type="text/javascript" src="../../src/debug.js"></script>
  12. <style type="text/css">
  13. html, body {
  14. font:normal 12px verdana;
  15. margin:0;
  16. padding:0;
  17. border:0 none;
  18. overflow:hidden;
  19. height:100%;
  20. }
  21. p {
  22. margin:5px;
  23. }
  24. .settings {
  25. background-image:url(../shared/icons/fam/folder_wrench.png);
  26. }
  27. .nav {
  28. background-image:url(../shared/icons/fam/folder_go.png);
  29. }
  30. </style>
  31. <script type="text/javascript">
  32. Ext.onReady(function(){
  33. Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
  34. Ext.ns('App');
  35. App.BookStore = function(config) {
  36. var config = config || {};
  37. Ext.applyIf(config, {
  38. reader: new Ext.data.XmlReader({
  39. // records will have an "Item" tag
  40. record: 'Item',
  41. id: 'ASIN',
  42. totalRecords: '@total'
  43. }, [
  44. // set up the fields mapping into the xml doc
  45. // The first needs mapping, the others are very basic
  46. {name: 'Author', mapping: 'ItemAttributes > Author'},
  47. 'Title',
  48. 'Manufacturer',
  49. 'ProductGroup',
  50. // Detail URL is not part of the column model of the grid
  51. 'DetailPageURL'
  52. ])
  53. });
  54. // call the superclass's constructor
  55. App.BookStore.superclass.constructor.call(this, config);
  56. };
  57. Ext.extend(App.BookStore, Ext.data.Store);
  58. App.BookGrid = Ext.extend(Ext.grid.GridPanel, {
  59. // override
  60. initComponent : function() {
  61. Ext.apply(this, {
  62. // Pass in a column model definition
  63. // Note that the DetailPageURL was defined in the record definition but is not used
  64. // here. That is okay.
  65. columns: [
  66. {header: "Author", width: 120, dataIndex: 'Author', sortable: true},
  67. {header: "Title", dataIndex: 'Title', sortable: true},
  68. {header: "Manufacturer", width: 115, dataIndex: 'Manufacturer', sortable: true},
  69. {header: "Product Group", dataIndex: 'ProductGroup', sortable: true}
  70. ],
  71. sm: new Ext.grid.RowSelectionModel({singleSelect: true}),
  72. // Note the use of a storeId, this will register thisStore
  73. // with the StoreMgr and allow us to retrieve it very easily.
  74. store: new App.BookStore({
  75. storeId: 'gridBookStore',
  76. url: 'sheldon.xml'
  77. }),
  78. // force the grid to fit the space which is available
  79. viewConfig: {
  80. forceFit: true
  81. }
  82. });
  83. // finally call the superclasses implementation
  84. App.BookGrid.superclass.initComponent.call(this);
  85. }
  86. });
  87. Ext.reg('bookgrid', App.BookGrid);
  88. /**
  89. * App.BookDetail
  90. * @extends Ext.Panel
  91. * This is a specialized Panel which is used to show information about
  92. * a book.
  93. *
  94. * This demonstrates adding 2 custom properties (tplMarkup and
  95. * startingMarkup) to the class. It also overrides the initComponent
  96. * method and adds a new method called updateDetail.
  97. *
  98. * The class will be registered with an xtype of 'bookdetail'
  99. */
  100. App.BookDetail = Ext.extend(Ext.Panel, {
  101. // add tplMarkup as a new property
  102. tplMarkup: [
  103. 'Title: <a href="{DetailPageURL}" target="_blank">{Title}</a><br/>',
  104. 'Author: {Author}<br/>',
  105. 'Manufacturer: {Manufacturer}<br/>',
  106. 'Product Group: {ProductGroup}<br/>'
  107. ],
  108. // startingMarup as a new property
  109. startingMarkup: 'Please select a book to see additional details',
  110. // override initComponent to create and compile the template
  111. // apply styles to the body of the panel and initialize
  112. // html to startingMarkup
  113. initComponent: function() {
  114. this.tpl = new Ext.Template(this.tplMarkup);
  115. Ext.apply(this, {
  116. bodyStyle: {
  117. background: '#ffffff',
  118. padding: '7px'
  119. },
  120. html: this.startingMarkup
  121. });
  122. // call the superclass's initComponent implementation
  123. App.BookDetail.superclass.initComponent.call(this);
  124. },
  125. // add a method which updates the details
  126. updateDetail: function(data) {
  127. this.tpl.overwrite(this.body, data);
  128. }
  129. });
  130. // register the App.BookDetail class with an xtype of bookdetail
  131. Ext.reg('bookdetail', App.BookDetail);
  132. /**
  133. * App.BookMasterDetail
  134. * @extends Ext.Panel
  135. *
  136. * This is a specialized panel which is composed of both a bookgrid
  137. * and a bookdetail panel. It provides the glue between the two
  138. * components to allow them to communicate. You could consider this
  139. * the actual application.
  140. *
  141. */
  142. App.BookMasterDetail = Ext.extend(Ext.Panel, {
  143. // override initComponent
  144. initComponent: function() {
  145. // used applyIf rather than apply so user could
  146. // override the defaults
  147. Ext.applyIf(this, {
  148. frame: true,
  149. title: 'Book List',
  150. width: 540,
  151. height: 400,
  152. layout: 'border',
  153. items: [{
  154. xtype: 'bookgrid',
  155. itemId: 'gridPanel',
  156. region: 'north',
  157. height: 210,
  158. split: true
  159. },{
  160. xtype: 'bookdetail',
  161. itemId: 'detailPanel',
  162. region: 'center'
  163. }]
  164. })
  165. // call the superclass's initComponent implementation
  166. App.BookMasterDetail.superclass.initComponent.call(this);
  167. },
  168. // override initEvents
  169. initEvents: function() {
  170. // call the superclass's initEvents implementation
  171. App.BookMasterDetail.superclass.initEvents.call(this);
  172. // now add application specific events
  173. // notice we use the selectionmodel's rowselect event rather
  174. // than a click event from the grid to provide key navigation
  175. // as well as mouse navigation
  176. var bookGridSm = this.getComponent('gridPanel').getSelectionModel();
  177. bookGridSm.on('rowselect', this.onRowSelect, this);
  178. },
  179. // add a method called onRowSelect
  180. // This matches the method signature as defined by the 'rowselect'
  181. // event defined in Ext.grid.RowSelectionModel
  182. onRowSelect: function(sm, rowIdx, r) {
  183. // getComponent will retrieve itemId's or id's. Note that itemId's
  184. // are scoped locally to this instance of a component to avoid
  185. // conflicts with the ComponentMgr
  186. var detailPanel = this.getComponent('detailPanel');
  187. detailPanel.updateDetail(r.data);
  188. }
  189. });
  190. // register an xtype with this class
  191. Ext.reg('bookmasterdetail', App.BookMasterDetail);
  192. // Finally now that we've defined all of our classes we can instantiate
  193. // an instance of the app and renderTo an existing div called 'binding-example'
  194. // Note now that classes have encapsulated this behavior we can easily create
  195. // an instance of this app to be used in many different contexts, you could
  196. // easily place this application in an Ext.Window for example
  197. // create an instance of the app
  198. var bookApp = new App.BookMasterDetail({
  199. renderTo: 'center2'
  200. });
  201. // We can retrieve a reference to the data store
  202. // via the StoreMgr by its storeId
  203. Ext.StoreMgr.get('gridBookStore').load();
  204. var viewport = new Ext.Viewport({
  205. id: 'viewport-component',
  206. layout:'border',
  207. items:[
  208. new Ext.BoxComponent({ // raw
  209. id:'north-panel',
  210. region:'north',
  211. el: 'north',
  212. height:32
  213. }),{
  214. id:'south-panel',
  215. region:'south',
  216. contentEl: 'south',
  217. split:true,
  218. height: 100,
  219. minSize: 100,
  220. maxSize: 200,
  221. collapsible: true,
  222. title:'South',
  223. margins:'0 0 0 0'
  224. }, {
  225. id:'east-panel',
  226. region:'east',
  227. title: 'East Side',
  228. collapsible: true,
  229. split:true,
  230. width: 225,
  231. minSize: 175,
  232. maxSize: 400,
  233. layout:'fit',
  234. margins:'0 5 0 0',
  235. items:
  236. new Ext.TabPanel({
  237. border:false,
  238. activeTab:1,
  239. tabPosition:'bottom',
  240. items:[{
  241. html:'<p>A TabPanel component can be a region.</p>',
  242. title: 'A Tab',
  243. autoScroll:true
  244. },
  245. new Ext.grid.PropertyGrid({
  246. id:'propGrid',
  247. title: 'Property Grid',
  248. closable: true,
  249. source: {
  250. "(name)": "Properties Grid",
  251. "grouping": false,
  252. "autoFitColumns": true,
  253. "productionQuality": false,
  254. "created": new Date(Date.parse('10/15/2006')),
  255. "tested": false,
  256. "version": .01,
  257. "borderWidth": 1
  258. }
  259. })]
  260. })
  261. },{
  262. region:'west',
  263. id:'west-panel',
  264. title:'West',
  265. split:true,
  266. width: 200,
  267. minSize: 175,
  268. maxSize: 400,
  269. collapsible: true,
  270. margins:'0 0 0 5',
  271. layout:'accordion',
  272. layoutConfig:{
  273. animate:true
  274. },
  275. items: [{
  276. id:'west-nav',
  277. contentEl: 'west',
  278. title:'Navigation',
  279. border:false,
  280. iconCls:'nav'
  281. },{
  282. id:'west-settings',
  283. title:'Settings',
  284. html:'<p>Some settings in here.</p>',
  285. border:false,
  286. iconCls:'settings'
  287. }]
  288. },
  289. new Ext.TabPanel({
  290. id:'center-region',
  291. region:'center',
  292. deferredRender:false,
  293. activeTab:0,
  294. items:[{
  295. id:'first-tab',
  296. contentEl:'center1',
  297. title: 'Close Me',
  298. closable:true,
  299. autoScroll:true
  300. },{
  301. id:'second-tab',
  302. contentEl:'center2',
  303. title: 'Center Panel',
  304. autoScroll:true
  305. }]
  306. })
  307. ]
  308. });
  309. });
  310. </script>
  311. </head>
  312. <body>
  313. <script type="text/javascript" src="../shared/examples.js"></script><!-- EXAMPLES -->
  314. <div id="west">
  315. <p>Hi. I'm the west panel.</p>
  316. </div>
  317. <div id="north">
  318. <p>north - generally for menus, toolbars and/or advertisements</p>
  319. </div>
  320. <div id="center2">
  321. </div>
  322. <div id="center1">
  323. <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>
  324. functionality cross browser. The most important feature is the "DOM Inspector" and CSS and DOM attribute editing. In any browser where "console"
  325. is not already defined, the Ext console will handle console.log(), time() and other calls.
  326. </p>
  327. <p>
  328. <b>Try It</b><br/>
  329. 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.
  330. </p>
  331. <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>
  332. <p>
  333. The full source is available in the "source" directory of the Ext download.
  334. </p>
  335. </div>
  336. <div id="props-panel" style="width:200px;height:200px;overflow:hidden;">
  337. </div>
  338. <div id="south">
  339. <p>south - generally for informational stuff, also could be for status bar</p>
  340. </div>
  341. </body>
  342. </html>