Created
August 11, 2012 04:48
-
-
Save pphetra/3321071 to your computer and use it in GitHub Desktop.
product grid
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> | |
| <link rel="stylesheet" href="www/extjs/resources/css/ext-all.css"> | |
| <script src="www/extjs/ext-all-debug.js"></script> | |
| <script> | |
| Ext.onReady(function() { | |
| Ext.define('Product', { | |
| extend: 'Ext.data.Model', | |
| idProperty: 'name', | |
| fields: [ | |
| 'name', | |
| { name: 'price', type: 'int' }, | |
| 'brand' | |
| ] | |
| }); | |
| Ext.define('Brand', { | |
| extend: 'Ext.data.Model', | |
| fields: [ | |
| 'name' | |
| ] | |
| }); | |
| var brandStore = Ext.create('Ext.data.Store', { | |
| model: 'Brand', | |
| data: [ | |
| { name: 'samsung' }, | |
| { name: 'sony' }, | |
| { name: 'acer' } | |
| ] | |
| }); | |
| var store = Ext.create('Ext.data.Store', { | |
| model: 'Product', | |
| idProperty: 'name', | |
| groupField: 'brand', | |
| data: [ | |
| { | |
| name: 'cx-3330', | |
| price: 100.00, | |
| brand: 'samsung' | |
| }, | |
| { | |
| name: 'cx-3430', | |
| price: 200.00, | |
| brand: 'samsung' | |
| }, | |
| { | |
| name: 'cx-1200', | |
| price: 100.00, | |
| brand: 'sony' | |
| }, | |
| { | |
| name: 'cx-2512', | |
| price: 200.00, | |
| brand: 'sony' | |
| }, | |
| { | |
| name: 'cx-1021', | |
| price: 100.00, | |
| brand: 'acer' | |
| }, | |
| { | |
| name: 'cx-3ddd', | |
| price: 200.00, | |
| brand: 'samsung' | |
| }, | |
| { | |
| name: 'cx-7451', | |
| price: 100.00, | |
| brand: 'acer' | |
| } | |
| ] | |
| }); | |
| Ext.create('Ext.container.Viewport', { | |
| layout: 'border', | |
| items: [ | |
| { | |
| region: 'center', | |
| xtype: 'grid', | |
| store: store, | |
| selType: 'cellmodel', | |
| plugins: [ | |
| Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }) | |
| ], | |
| features: [ | |
| //{ftype: 'grouping'}, | |
| ], | |
| columns: [ | |
| { | |
| header: 'Name', | |
| dataIndex: 'name', | |
| width: 100, | |
| field: { | |
| xtype: 'textfield' | |
| } | |
| }, | |
| { | |
| header: 'Brand', | |
| dataIndex: 'brand', | |
| flex: 1, | |
| field: { | |
| xtype: 'combo', // ระบุ xtype | |
| store: brandStore, | |
| displayField: 'name', | |
| queryMode: 'local' | |
| } | |
| }, | |
| { | |
| header: 'price', | |
| dataIndex: 'price', | |
| width: 100, | |
| field: { | |
| xtype: 'numberfield' | |
| } | |
| } | |
| ] | |
| } | |
| ] | |
| }); | |
| }); | |
| </script> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment