4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-grid-column-Template'>/**
19 </span> * A Column definition class which renders a value by processing a {@link Ext.data.Model Model}'s
20 * {@link Ext.data.Model#persistenceProperty data} using a {@link #tpl configured}
21 * {@link Ext.XTemplate XTemplate}.
24 * Ext.create('Ext.data.Store', {
25 * storeId:'employeeStore',
26 * fields:['firstname', 'lastname', 'senority', 'department'],
27 * groupField: 'department',
29 * { firstname: "Michael", lastname: "Scott", senority: 7, department: "Manangement" },
30 * { firstname: "Dwight", lastname: "Schrute", senority: 2, department: "Sales" },
31 * { firstname: "Jim", lastname: "Halpert", senority: 3, department: "Sales" },
32 * { firstname: "Kevin", lastname: "Malone", senority: 4, department: "Accounting" },
33 * { firstname: "Angela", lastname: "Martin", senority: 5, department: "Accounting" }
37 * Ext.create('Ext.grid.Panel', {
38 * title: 'Column Template Demo',
39 * store: Ext.data.StoreManager.lookup('employeeStore'),
41 * { text: 'Full Name', xtype: 'templatecolumn', tpl: '{firstname} {lastname}', flex:1 },
42 * { text: 'Deparment (Yrs)', xtype: 'templatecolumn', tpl: '{department} ({senority})' }
46 * renderTo: Ext.getBody()
49 Ext.define('Ext.grid.column.Template', {
50 extend: 'Ext.grid.column.Column',
51 alias: ['widget.templatecolumn'],
52 requires: ['Ext.XTemplate'],
53 alternateClassName: 'Ext.grid.TemplateColumn',
55 <span id='Ext-grid-column-Template-cfg-tpl'> /**
56 </span> * @cfg {String/Ext.XTemplate} tpl
57 * An {@link Ext.XTemplate XTemplate}, or an XTemplate *definition string* to use to process a
58 * {@link Ext.data.Model Model}'s {@link Ext.data.Model#persistenceProperty data} to produce a
59 * column's rendered value.
62 constructor: function(cfg){
66 me.callParent(arguments);
67 tpl = me.tpl = (!Ext.isPrimitive(me.tpl) && me.tpl.compile) ? me.tpl : Ext.create('Ext.XTemplate', me.tpl);
69 me.renderer = function(value, p, record) {
70 var data = Ext.apply({}, record.data, record.getAssociatedData());
71 return tpl.apply(data);