actions.html 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. <p>Click the buttons below to perform actions.</p>
  15. <div style="margin:20px 0;">
  16. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="collapseAll()">CollapseAll</a>
  17. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="expandAll()">ExpandAll</a>
  18. <a href="javascript:void(0)" class="easyui-linkbutton" onclick="expandTo()">ExpandTo</a>
  19. </div>
  20. <table id="tg" class="easyui-treegrid" title="TreeGrid Actions" style="width:700px;height:250px"
  21. data-options="
  22. iconCls: 'icon-ok',
  23. rownumbers: true,
  24. animate: true,
  25. collapsible: true,
  26. fitColumns: true,
  27. url: 'treegrid_data2.json',
  28. method: 'get',
  29. idField: 'id',
  30. treeField: 'name'
  31. ">
  32. <thead>
  33. <tr>
  34. <th data-options="field:'name',width:180">Task Name</th>
  35. <th data-options="field:'persons',width:60,align:'right'">Persons</th>
  36. <th data-options="field:'begin',width:80">Begin Date</th>
  37. <th data-options="field:'end',width:80">End Date</th>
  38. <th data-options="field:'progress',width:120,formatter:formatProgress">Progress</th>
  39. </tr>
  40. </thead>
  41. </table>
  42. <script type="text/javascript">
  43. function formatProgress(value){
  44. if (value){
  45. var s = '<div style="width:100%;border:1px solid #ccc">' +
  46. '<div style="width:' + value + '%;background:#cc0000;color:#fff">' + value + '%' + '</div>'
  47. '</div>';
  48. return s;
  49. } else {
  50. return '';
  51. }
  52. }
  53. function collapseAll(){
  54. $('#tg').treegrid('collapseAll');
  55. }
  56. function expandAll(){
  57. $('#tg').treegrid('expandAll');
  58. }
  59. function expandTo(){
  60. $('#tg').treegrid('expandTo',21).treegrid('select',21);
  61. }
  62. </script>
  63. </body>
  64. </html>