Created
June 29, 2013 08:40
-
-
Save pphetra/5890393 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>Template</title> | |
| <link rel="stylesheet" href="extjs/resources/css/ext-all.css"> | |
| <script src="extjs/ext-all-debug.js"></script> | |
| <script> | |
| // รอให้ page load เสร้จแล้วค่อยทำงาน | |
| Ext.onReady(function() { | |
| Ext.define('Car', { | |
| extend: 'Ext.data.Model', | |
| fields: [ | |
| 'id', | |
| 'chassieNo', | |
| 'engineNo', | |
| 'licenseNo', | |
| 'brand', | |
| {name: 'price', type: 'float'} | |
| ] | |
| }); | |
| var carStore = Ext.create('Ext.data.Store', { | |
| model: 'Car', | |
| proxy: { | |
| type: 'memory' | |
| } | |
| }); | |
| var c1 = Ext.create('Car', { | |
| id: 1, | |
| chassieNo: '2434343', | |
| engineNo: 'xx0dfdfd9000', | |
| licenseNo: '1234', | |
| brand: 'toyota', | |
| price: 200000 | |
| }); | |
| var c2 = Ext.create('Car', { | |
| id: 2, | |
| chassieNo: '99909090', | |
| engineNo: 'd00d9090', | |
| licenseNo: '1120', | |
| brand: 'toyota', | |
| price: 200000 | |
| }); | |
| var c3 = Ext.create('Car', { | |
| id: 2, | |
| chassieNo: '99909090', | |
| engineNo: '9909090', | |
| licenseNo: '7789', | |
| brand: 'isuzu', | |
| price: 600000 | |
| }); | |
| carStore.add(c1); | |
| carStore.add(c2); | |
| carStore.add(c3); | |
| var grid = Ext.create('Ext.grid.Panel', { | |
| store: carStore, | |
| columns: [ | |
| { | |
| header: 'Chassie', | |
| dataIndex: 'chassieNo', | |
| width: 150 | |
| }, | |
| { | |
| header: 'Engine', | |
| dataIndex: 'engineNo', | |
| flex: 1, | |
| renderer: function(value) { | |
| return "--" + value; | |
| } | |
| }, | |
| { | |
| header: 'mixed', | |
| xtype: 'templatecolumn', | |
| tpl: '{brand} {price}' | |
| }, | |
| { | |
| header: 'Brand', | |
| dataIndex: 'brand' | |
| }, | |
| { | |
| header: 'Price', | |
| dataIndex: 'price', | |
| renderer: Ext.util.Format.numberRenderer('0,000.00') | |
| } | |
| ] | |
| }); | |
| var viewport = Ext.create('Ext.container.Viewport', { | |
| layout: 'fit', | |
| items: [ | |
| grid | |
| ] | |
| }); | |
| }); | |
| </script> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment