3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
21 Ext.onReady(function() {
22 //we want to setup a model and store instead of using dataUrl
24 extend: 'Ext.data.Model',
26 {name: 'task', type: 'string'},
27 {name: 'user', type: 'string'},
28 {name: 'duration', type: 'string'}
32 var store = Ext.create('Ext.data.TreeStore', {
36 //the store will get the content from the .json file
42 //Ext.ux.tree.TreeGrid is no longer a Ux. You can simply use a tree.TreePanel
43 var tree = Ext.create('Ext.tree.Panel', {
44 title: 'Core Team Projects',
47 renderTo: Ext.getBody(),
54 //the 'columns' property is now 'headers'
56 xtype: 'treecolumn', //this is so we know which column will show the tree
62 //we must use the templateheader component so we can use a custom tpl
63 xtype: 'templatecolumn',
67 dataIndex: 'duration',
69 //add in the custom tpl for the rows
70 tpl: Ext.create('Ext.XTemplate', '{duration:this.formatHours}', {
71 formatHours: function(v) {
73 return Math.round(v * 60) + ' mins';
74 } else if (Math.floor(v) !== v) {
75 var min = v - Math.floor(v);
76 return Math.floor(v) + 'h ' + Math.round(min * 60) + 'm';
78 return v + ' hour' + (v === 1 ? '' : 's');