actions.html 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>TreeGrid Actions - jQuery EasyUI Demo</title>
  6. <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
  7. <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
  8. <link rel="stylesheet" type="text/css" href="../demo.css">
  9. <script type="text/javascript" src="../../jquery.min.js"></script>
  10. <script type="text/javascript" src="../../jquery.easyui.min.js"></script>
  11. </head>
  12. <body>
  13. <h2>TreeGrid Actions</h2>
  14. <div class="demo-info">
  15. <div class="demo-tip icon-tip"></div>
  16. <div>Click the buttons below to perform actions.</div>
  17. </div>
  18. <div style="margin:10px 0;">
  19. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="collapseAll()">CollapseAll</a>
  20. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="expandAll()">ExpandAll</a>
  21. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="expandTo()">ExpandTo</a>
  22. </div>
  23. <table id="tg" class="easyui-treegrid" title="TreeGrid Actions" style="width:700px;height:250px"
  24. data-options="
  25. iconCls: 'icon-ok',
  26. rownumbers: true,
  27. animate: true,
  28. collapsible: true,
  29. fitColumns: true,
  30. url: 'treegrid_data2.json',
  31. method: 'get',
  32. idField: 'id',
  33. treeField: 'name'
  34. ">
  35. <thead>
  36. <tr>
  37. <th data-options="field:'name',width:180">Task Name</th>
  38. <th data-options="field:'persons',width:60,align:'right'">Persons</th>
  39. <th data-options="field:'begin',width:80">Begin Date</th>
  40. <th data-options="field:'end',width:80">End Date</th>
  41. <th data-options="field:'progress',width:120,formatter:formatProgress">Progress</th>
  42. </tr>
  43. </thead>
  44. </table>
  45. <script type="text/javascript">
  46. function formatProgress(value){
  47. if (value){
  48. var s = '<div style="width:100%;border:1px solid #ccc">' +
  49. '<div style="width:' + value + '%;background:#cc0000;color:#fff">' + value + '%' + '</div>'
  50. '</div>';
  51. return s;
  52. } else {
  53. return '';
  54. }
  55. }
  56. function collapseAll(){
  57. $('#tg').treegrid('collapseAll');
  58. }
  59. function expandAll(){
  60. $('#tg').treegrid('expandAll');
  61. }
  62. function expandTo(){
  63. $('#tg').treegrid('expandTo',21).treegrid('select',21);
  64. }
  65. </script>
  66. </body>
  67. </html>