4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../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> * @class Ext.grid.column.Template
20 * @extends Ext.grid.column.Column
22 * A Column definition class which renders a value by processing a {@link Ext.data.Model Model}'s
23 * {@link Ext.data.Model#data data} using a {@link #tpl configured} {@link Ext.XTemplate XTemplate}.
25 * {@img Ext.grid.column.Template/Ext.grid.column.Template.png Ext.grid.column.Template grid column}
28 * Ext.create('Ext.data.Store', {
29 * storeId:'employeeStore',
30 * fields:['firstname', 'lastname', 'senority', 'department'],
31 * groupField: 'department',
33 * {firstname:"Michael", lastname:"Scott", senority:7, department:"Manangement"},
34 * {firstname:"Dwight", lastname:"Schrute", senority:2, department:"Sales"},
35 * {firstname:"Jim", lastname:"Halpert", senority:3, department:"Sales"},
36 * {firstname:"Kevin", lastname:"Malone", senority:4, department:"Accounting"},
37 * {firstname:"Angela", lastname:"Martin", senority:5, department:"Accounting"}
41 * Ext.create('Ext.grid.Panel', {
42 * title: 'Column Template Demo',
43 * store: Ext.data.StoreManager.lookup('employeeStore'),
45 * {text: 'Full Name', xtype:'templatecolumn', tpl:'{firstname} {lastname}', flex:1},
46 * {text: 'Deparment (Yrs)', xtype:'templatecolumn', tpl:'{department} ({senority})'}
50 * renderTo: Ext.getBody()
54 * @xtype templatecolumn
56 Ext.define('Ext.grid.column.Template', {
57 extend: 'Ext.grid.column.Column',
58 alias: ['widget.templatecolumn'],
59 requires: ['Ext.XTemplate'],
60 alternateClassName: 'Ext.grid.TemplateColumn',
62 <span id='Ext-grid-column-Template-cfg-tpl'> /**
63 </span> * @cfg {String/XTemplate} tpl
64 * An {@link Ext.XTemplate XTemplate}, or an XTemplate <i>definition string</i> to use to process a
65 * {@link Ext.data.Model Model}'s {@link Ext.data.Model#data data} to produce a column's rendered value.
67 constructor: function(cfg){
71 me.callParent(arguments);
72 tpl = me.tpl = (!Ext.isPrimitive(me.tpl) && me.tpl.compile) ? me.tpl : Ext.create('Ext.XTemplate', me.tpl);
74 me.renderer = function(value, p, record) {
75 var data = Ext.apply({}, record.data, record.getAssociatedData());
76 return tpl.apply(data);