home2.jsp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <%@ page language="java" pageEncoding="utf-8"%>
  2. <%
  3. String path = request.getContextPath();
  4. String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
  5. %>
  6. <!DOCTYPE html>
  7. <html>
  8. <head>
  9. <link rel="stylesheet" href="<%=basePath %>resource/ext/resources/css/ext-all-gray.css" type="text/css"></link>
  10. <!--[if IE]>
  11. <link rel="stylesheet" href="<%=basePath %>resource/ext/resources/css/ext-ie-scoped.css" type="text/css"></link>
  12. <![endif]-->
  13. <%-- <link rel="stylesheet" href="<%=basePath %>resource/css/main.css" type="text/css"></link> --%>
  14. <script type="text/javascript" src="<%=basePath %>resource/ext/ext-all.js"></script>
  15. <script>
  16. Ext.require([
  17. 'Ext.data.*',
  18. 'Ext.grid.*',
  19. 'Ext.tree.*'
  20. ]);
  21. Ext.onReady(function() {
  22. //we want to setup a model and store instead of using dataUrl
  23. //Ext.ux.tree.TreeGrid is no longer a Ux. You can simply use a tree.TreePanel
  24. Ext.create('Ext.tree.TreePanel',{
  25. title: 'Tree Grid',
  26. width: window.innerWidth,
  27. height: window.innerHeight,
  28. renderTo: Ext.getBody(),
  29. useArrows: true,
  30. rootVisible: false,
  31. store: Ext.create('Ext.data.TreeStore',{
  32. root: {
  33. text: 'root',
  34. id: 'root',
  35. expanded: true,
  36. children: [
  37. {
  38. text:'Project: Shopping',
  39. duration:13.25,
  40. user:'Tommy Maintz',
  41. iconCls:'text-folder',
  42. expanded: true,
  43. children:[{
  44. text:'Housewares',
  45. duration:1.25,
  46. user:'Tommy Maintz',
  47. iconCls:'text-folder',
  48. children:[{
  49. text:'Kitchen supplies',
  50. duration:0.25,
  51. user:'Tommy Maintz',
  52. leaf:true,
  53. iconCls:'text'
  54. },{
  55. text:'Groceries',
  56. duration:.4,
  57. user:'Tommy Maintz',
  58. leaf:true,
  59. iconCls:'text'
  60. },{
  61. text:'Cleaning supplies',
  62. duration:.4,
  63. user:'Tommy Maintz',
  64. leaf:true,
  65. iconCls:'text'
  66. },{
  67. text: 'Office supplies',
  68. duration: .2,
  69. user: 'Tommy Maintz',
  70. leaf: true,
  71. iconCls: 'text'
  72. }]
  73. }]
  74. }]
  75. }
  76. }),
  77. //the 'columns' property is now 'headers'
  78. headers: [{
  79. xtype: 'treeheader', //this is so we know which column will show the tree
  80. text: 'Task',
  81. flex: 2,
  82. dataIndex: 'task'
  83. },{
  84. //we must use the templateheader component so we can use a custom tpl
  85. xtype: 'templateheader',
  86. text: 'Duration',
  87. flex: 1,
  88. dataIndex: 'duration',
  89. align: 'center',
  90. //add in the custom tpl for the rows
  91. tpl: new Ext.XTemplate('{duration:this.formatHours}', {
  92. formatHours: function(v) {
  93. if (v < 1) {
  94. return Math.round(v * 60) + ' mins';
  95. } else if (Math.floor(v) !== v) {
  96. var min = v - Math.floor(v);
  97. return Math.floor(v) + 'h ' + Math.round(min * 60) + 'm';
  98. } else {
  99. return v + ' hour' + (v === 1 ? '' : 's');
  100. }
  101. }
  102. })
  103. },{
  104. text: 'Assigned To',
  105. flex: 1,
  106. dataIndex: 'user'
  107. }]
  108. });
  109. });
  110. var basePath = '<%=basePath %>';
  111. </script>
  112. </head>
  113. <body>
  114. </body>
  115. </html>