7 Ext.onReady(function() {
8 //we want to setup a model and store instead of using dataUrl
10 extend: 'Ext.data.Model',
12 {name: 'task', type: 'string'},
13 {name: 'user', type: 'string'},
14 {name: 'duration', type: 'string'}
18 var store = Ext.create('Ext.data.TreeStore', {
22 //the store will get the content from the .json file
28 //Ext.ux.tree.TreeGrid is no longer a Ux. You can simply use a tree.TreePanel
29 var tree = Ext.create('Ext.tree.Panel', {
30 title: 'Core Team Projects',
33 renderTo: Ext.getBody(),
40 //the 'columns' property is now 'headers'
42 xtype: 'treecolumn', //this is so we know which column will show the tree
48 //we must use the templateheader component so we can use a custom tpl
49 xtype: 'templatecolumn',
53 dataIndex: 'duration',
55 //add in the custom tpl for the rows
56 tpl: Ext.create('Ext.XTemplate', '{duration:this.formatHours}', {
57 formatHours: function(v) {
59 return Math.round(v * 60) + ' mins';
60 } else if (Math.floor(v) !== v) {
61 var min = v - Math.floor(v);
62 return Math.floor(v) + 'h ' + Math.round(min * 60) + 'm';
64 return v + ' hour' + (v === 1 ? '' : 's');