]>
git.proxmox.com Git - extjs.git/blob - extjs/build/examples/kitchensink/classic/samples/view/form/FormGrid.js
2 * This Form demonstrates the fact that by virtue of inheriting from the Ext.Container
3 * class, an Ext.form.Panel can contain any Ext.Component. This includes all the
4 * subclasses of Ext.Panel, including the GridPanel.
6 * The Grid demonstrates the use of creation of derived fields in a Record created using a
7 * custom `convert` function, and the use of column renderers.
9 * The Form demonstrates the use of radio buttons grouped by name being set by the value
10 * of the derived rating field.
12 Ext
.define('KitchenSink.view.form.FormGrid', {
13 extend
: 'Ext.form.Panel',
20 'Ext.layout.container.Column',
21 'KitchenSink.model.Company'
24 exampleTitle
: 'Dynamic Form interacting with an embedded Grid',
27 path
: 'classic/samples/model/Company.js'
34 percentChangeColumnWidth
: 75,
35 lastUpdatedColumnWidth
: 85,
42 percentChangeColumnWidth
: 100,
43 lastUpdatedColumnWidth
: 115,
50 title
: 'Company data',
54 // In this example, configuration is applied at initComponent time
55 // because it depends on profileInfo object that is generated for the
57 initComponent: function() {
59 width
: this.profileInfo
.width
,
68 columnWidth
: this.profileInfo
.gridWidth
,
70 store
: new Ext
.data
.Store({
71 model
: KitchenSink
.model
.Company
,
78 data
: KitchenSink
.data
.DataSets
.company
95 renderer
: this.changeRenderer
,
99 width
: this.profileInfo
.percentChangeColumnWidth
,
101 renderer
: this.pctChangeRenderer
,
102 dataIndex
: 'pctChange'
104 text
: 'Last Updated',
105 width
: this.profileInfo
.lastUpdatedColumnWidth
,
107 formatter
: 'date("m/d/Y")',
108 dataIndex
: 'lastChange'
111 width
: this.profileInfo
.ratingColumnWidth
,
113 renderer
: this.renderRating
,
118 selectionchange
: this.onSelectionChange
121 columnWidth
: this.profileInfo
.formWidth
,
124 title
:'Company details',
126 defaultType
: 'textfield',
134 fieldLabel
: '% Change',
138 fieldLabel
: 'Last Updated',
142 fieldLabel
: 'Rating',
145 name
: 'rating' //Each radio has the same name so the browser will make sure only one is checked at once
163 changeRenderer: function(val
) {
165 return '<span style="color:green;">' + val
+ '</span>';
167 return '<span style="color:red;">' + val
+ '</span>';
172 pctChangeRenderer: function(val
){
174 return '<span style="color:green;">' + val
+ '%</span>';
176 return '<span style="color:red;">' + val
+ '%</span>';
181 renderRating: function(val
){
192 onSelectionChange: function(model
, records
) {
193 var rec
= records
[0];
195 this.getForm().loadRecord(rec
);