| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <%@ page language="java" pageEncoding="utf-8"%>
- <%
- String path = request.getContextPath();
- String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
- %>
- <!DOCTYPE html>
- <html>
- <head>
- <link rel="stylesheet" href="<%=basePath %>resource/ext/resources/css/ext-all-gray.css" type="text/css"></link>
- <!--[if IE]>
- <link rel="stylesheet" href="<%=basePath %>resource/ext/resources/css/ext-ie-scoped.css" type="text/css"></link>
- <![endif]-->
- <%-- <link rel="stylesheet" href="<%=basePath %>resource/css/main.css" type="text/css"></link> --%>
- <script type="text/javascript" src="<%=basePath %>resource/ext/ext-all.js"></script>
- <script>
- Ext.require([
- 'Ext.data.*',
- 'Ext.grid.*',
- 'Ext.tree.*'
- ]);
- Ext.onReady(function() {
- //we want to setup a model and store instead of using dataUrl
- //Ext.ux.tree.TreeGrid is no longer a Ux. You can simply use a tree.TreePanel
- Ext.create('Ext.tree.TreePanel',{
- title: 'Tree Grid',
- width: window.innerWidth,
- height: window.innerHeight,
- renderTo: Ext.getBody(),
- useArrows: true,
- rootVisible: false,
- store: Ext.create('Ext.data.TreeStore',{
- root: {
- text: 'root',
- id: 'root',
- expanded: true,
- children: [
- {
- text:'Project: Shopping',
- duration:13.25,
- user:'Tommy Maintz',
- iconCls:'text-folder',
- expanded: true,
- children:[{
- text:'Housewares',
- duration:1.25,
- user:'Tommy Maintz',
- iconCls:'text-folder',
- children:[{
- text:'Kitchen supplies',
- duration:0.25,
- user:'Tommy Maintz',
- leaf:true,
- iconCls:'text'
- },{
- text:'Groceries',
- duration:.4,
- user:'Tommy Maintz',
- leaf:true,
- iconCls:'text'
- },{
- text:'Cleaning supplies',
- duration:.4,
- user:'Tommy Maintz',
- leaf:true,
- iconCls:'text'
- },{
- text: 'Office supplies',
- duration: .2,
- user: 'Tommy Maintz',
- leaf: true,
- iconCls: 'text'
- }]
- }]
- }]
- }
- }),
- //the 'columns' property is now 'headers'
- headers: [{
- xtype: 'treeheader', //this is so we know which column will show the tree
- text: 'Task',
- flex: 2,
- dataIndex: 'task'
- },{
- //we must use the templateheader component so we can use a custom tpl
- xtype: 'templateheader',
- text: 'Duration',
- flex: 1,
- dataIndex: 'duration',
- align: 'center',
- //add in the custom tpl for the rows
- tpl: new Ext.XTemplate('{duration:this.formatHours}', {
- formatHours: function(v) {
- if (v < 1) {
- return Math.round(v * 60) + ' mins';
- } else if (Math.floor(v) !== v) {
- var min = v - Math.floor(v);
- return Math.floor(v) + 'h ' + Math.round(min * 60) + 'm';
- } else {
- return v + ' hour' + (v === 1 ? '' : 's');
- }
- }
- })
- },{
- text: 'Assigned To',
- flex: 1,
- dataIndex: 'user'
- }]
- });
- });
- var basePath = '<%=basePath %>';
- </script>
- </head>
- <body>
- </body>
- </html>
|