]> git.proxmox.com Git - extjs.git/blame - extjs/examples/kitchensink/classic/samples/view/form/FileUploads.js
add extjs 6.0.1 sources
[extjs.git] / extjs / examples / kitchensink / classic / samples / view / form / FileUploads.js
CommitLineData
6527f429
DM
1/**\r
2 * This example demonstrates use of Ext.form.field.File, a file upload field with custom\r
3 * rendering, and error handling.\r
4 */\r
5Ext.define('KitchenSink.view.form.FileUploads', {\r
6 extend: 'Ext.container.Container',\r
7 xtype: 'form-fileuploads',\r
8 controller: 'form-fileuploads',\r
9 \r
10 //<example>\r
11 requires: [\r
12 'KitchenSink.view.form.FileUploadsController'\r
13 ],\r
14 \r
15 exampleTitle: 'File Upload fields',\r
16 otherContent: [{\r
17 type: 'ViewController',\r
18 path: 'classic/samples/view/form/FileUploadsController.js'\r
19 }],\r
20 //</example>\r
21 \r
22 width: 600,\r
23 layout: {\r
24 type: 'vbox',\r
25 align: 'stretch'\r
26 },\r
27 \r
28 defaults: {\r
29 xtype: 'form',\r
30 layout: 'anchor',\r
31\r
32 bodyPadding: 10,\r
33 style: {\r
34 'margin-bottom': '20px'\r
35 },\r
36 \r
37 defaults: {\r
38 anchor: '100%'\r
39 }\r
40 },\r
41 \r
42 items: [{\r
43 items: [{\r
44 xtype: 'component',\r
45 html: [\r
46 '<h3>Basic File Field</h3>',\r
47 '<p>A typical file upload field with Ext style. Direct editing ',\r
48 'of the text field cannot be done in a consistent, cross-browser way, ',\r
49 'so it is always read-only. The file path reported by the ',\r
50 '<code>getValue</code> method will depend on the browser and cannot ',\r
51 'be controlled by Ext JS.'\r
52 ]\r
53 }, {\r
54 xtype: 'filefield',\r
55 hideLabel: true,\r
56 reference: 'basicFile'\r
57 }, {\r
58 xtype: 'button',\r
59 text: 'Get File Path',\r
60 handler: 'getFilePath'\r
61 }]\r
62 }, {\r
63 items: [{\r
64 xtype: 'component',\r
65 html: [\r
66 '<h3>Button Only</h3>',\r
67 '<p>You can also render the file input as a button without ',\r
68 'the text field, with access to the field\'s value via the ',\r
69 'standard <tt>Ext.form.field.Field</tt> interface or by handling ',\r
70 'the <tt>change</tt> event (as in this example).',\r
71 '</p>'\r
72 ]\r
73 }, {\r
74 xtype: 'fileuploadfield', // Same as filefield above\r
75 buttonOnly: true,\r
76 hideLabel: true,\r
77 listeners: {\r
78 change: 'buttonOnlyChange'\r
79 }\r
80 }]\r
81 }, {\r
82 title: 'File Upload Form',\r
83 frame: true,\r
84 bodyPadding: '10 10 0',\r
85 reference: 'firstForm',\r
86\r
87 defaults: {\r
88 anchor: '100%',\r
89 allowBlank: false,\r
90 msgTarget: 'side',\r
91 labelWidth: 50\r
92 },\r
93\r
94 items: [{\r
95 xtype: 'textfield',\r
96 fieldLabel: 'Name'\r
97 }, {\r
98 xtype: 'filefield',\r
99 emptyText: 'Select an image',\r
100 fieldLabel: 'Photo',\r
101 name: 'photo-path',\r
102 buttonText: '',\r
103 buttonConfig: {\r
104 iconCls: 'file-uploads-image-add'\r
105 }\r
106 }],\r
107\r
108 buttons: [{\r
109 text: 'Save',\r
110 handler: 'firstFormSave'\r
111 }, {\r
112 text: 'Reset',\r
113 handler: 'firstFormReset'\r
114 }]\r
115 }, {\r
116 title: 'Upload error test',\r
117 frame: true,\r
118 bodyPadding: '10 10 0',\r
119 reference: 'secondForm',\r
120\r
121 defaults: {\r
122 anchor: '100%',\r
123 allowBlank: false,\r
124 msgTarget: 'side',\r
125 labelWidth: 70\r
126 },\r
127\r
128 items: [{\r
129 xtype: 'textfield',\r
130 fieldLabel: 'Name'\r
131 }, {\r
132 xtype: 'filefield',\r
133 emptyText: 'Select an image',\r
134 fieldLabel: 'Photo',\r
135 name: 'photo-path',\r
136 buttonConfig: {\r
137 text : '',\r
138 iconCls: 'file-uploads-image-add'\r
139 }\r
140 }, {\r
141 xtype: 'numberfield',\r
142 fieldLabel: 'HTTP status',\r
143 value: 200,\r
144 minValue: 200,\r
145 maxValue: 599,\r
146 name: 'returnResponse'\r
147 }],\r
148\r
149 buttons: [{\r
150 text: 'Save',\r
151 handler: 'secondFormSubmit'\r
152 }, {\r
153 text: 'Reset',\r
154 handler: 'secondFormReset'\r
155 }]\r
156 }]\r
157});\r