app.js
1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* @example Renderers
*
* This grid demonstrates the use of a couple different custom renderers.
* The birth date field is rendered using a date formatter, and the email address is rendered as a hyperlink.
*/
Ext.require('Ext.data.Store');
Ext.require('Ext.grid.Panel');
Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{ name: 'name', type: 'string' },
{ name: 'email', type: 'string' },
{ name: 'birthDate', type: 'date' }
]
});
Ext.onReady(function() {
var userStore = Ext.create('Ext.data.Store', {
model: 'User',
data: [
{ name: 'Lisa', email: 'lisa@simpsons.com', birthDate: new Date(1981, 9, 28) },
{ name: 'Bart', email: 'bart@simpsons.com', birthDate: new Date(1979, 4, 1) },
{ name: 'Homer', email: 'home@simpsons.com', birthDate: new Date(1956, 3, 15) },
{ name: 'Marge', email: 'marge@simpsons.com', birthDate: new Date(1954, 10, 1) }
]
});
Ext.create('Ext.grid.Panel', {
renderTo: Ext.getBody(),
store: userStore,
width: 500,
height: 300,
title: 'Application Users',
columns: [
{
text: 'Name',
width: 150,
dataIndex: 'name'
},
{
text: 'Birth Date',
width: 75,
dataIndex: 'birthDate',
// format the date using a renderer from the Ext.util.Format class
renderer: Ext.util.Format.dateRenderer('m/d/Y')
},
{
text: 'Email Address',
flex: 1,
dataIndex: 'email',
// format the email address using a custom renderer
renderer: function(value) {
return Ext.String.format('<a href="mailto:{0}">{1}</a>', value, value);
}
}
]
});
});