1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-grid.column.Template'>/**
2 </span> * @class Ext.grid.column.Template
3 * @extends Ext.grid.column.Column
5 * A Column definition class which renders a value by processing a {@link Ext.data.Model Model}'s
6 * {@link Ext.data.Model#data data} using a {@link #tpl configured} {@link Ext.XTemplate XTemplate}.
8 * {@img Ext.grid.column.Template/Ext.grid.column.Template.png Ext.grid.column.Template grid column}
11 * Ext.create('Ext.data.Store', {
12 * storeId:'employeeStore',
13 * fields:['firstname', 'lastname', 'senority', 'department'],
14 * groupField: 'department',
16 * {firstname:"Michael", lastname:"Scott", senority:7, department:"Manangement"},
17 * {firstname:"Dwight", lastname:"Schrute", senority:2, department:"Sales"},
18 * {firstname:"Jim", lastname:"Halpert", senority:3, department:"Sales"},
19 * {firstname:"Kevin", lastname:"Malone", senority:4, department:"Accounting"},
20 * {firstname:"Angela", lastname:"Martin", senority:5, department:"Accounting"}
24 * Ext.create('Ext.grid.Panel', {
25 * title: 'Column Template Demo',
26 * store: Ext.data.StoreManager.lookup('employeeStore'),
28 * {text: 'Full Name', xtype:'templatecolumn', tpl:'{firstname} {lastname}', flex:1},
29 * {text: 'Deparment (Yrs)', xtype:'templatecolumn', tpl:'{department} ({senority})'}
33 * renderTo: Ext.getBody()
37 * @xtype templatecolumn
39 Ext.define('Ext.grid.column.Template', {
40 extend: 'Ext.grid.column.Column',
41 alias: ['widget.templatecolumn'],
42 requires: ['Ext.XTemplate'],
43 alternateClassName: 'Ext.grid.TemplateColumn',
45 <span id='Ext-grid.column.Template-cfg-tpl'> /**
46 </span> * @cfg {String/XTemplate} tpl
47 * An {@link Ext.XTemplate XTemplate}, or an XTemplate <i>definition string</i> to use to process a
48 * {@link Ext.data.Model Model}'s {@link Ext.data.Model#data data} to produce a column's rendered value.
50 constructor: function(cfg){
54 me.callParent(arguments);
55 tpl = me.tpl = (!Ext.isPrimitive(me.tpl) && me.tpl.compile) ? me.tpl : Ext.create('Ext.XTemplate', me.tpl);
57 me.renderer = function(value, p, record) {
58 var data = Ext.apply({}, record.data, record.getAssociatedData());
59 return tpl.apply(data);
63 </pre></pre></body></html>