grid-two.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. define(function (require) {
  2. return function () {
  3. var $grid;
  4. var toolbar = {
  5. xtype: 'toolbar',
  6. title: '工具条',
  7. items: [
  8. {
  9. text: '新增', iconCls: 'fa fa-plus-circle fa-lg', onClick: function () {
  10. }
  11. }, {
  12. text: '编辑', iconCls: 'fa fa fa-pencil-square-o fa-lg', onClick: function () {
  13. $.yvan.msg('编辑');
  14. }
  15. }, {
  16. text: '设置列宽', iconCls: 'fa fa-save', onClick: function () {
  17. //$grid.setColProp('idDesc', { width: 400 });
  18. //console.log($grid.getColProp('idDesc'));
  19. //$grid.trigger('resize');
  20. //$grid.jqGrid('setColWidth', '[idName,idDesc]', [300, 400]);
  21. $grid.jqGrid('autoResizeColumn', 3);
  22. }
  23. }, {
  24. text: '删除', iconCls: 'fa fa-minus-square fa-lg', onClick: function () {
  25. $.yvan.msg('删除');
  26. }
  27. }, '|', {
  28. text: '关闭', iconCls: 'fa fa-times-circle fa-lg', onClick: function () {
  29. App.closeMe(this);
  30. }
  31. }
  32. ]
  33. };
  34. //var toolbar = [
  35. // {
  36. // text: '新增', iconCls: 'fa fa-plus-circle fa-lg', onClick: function () {
  37. // $.yvan.msg('新增');
  38. // }
  39. // }, {
  40. // text: '编辑', iconCls: 'fa fa fa-pencil-square-o fa-lg', onClick: function () {
  41. // $.yvan.msg('编辑');
  42. // }
  43. // }, {
  44. // text: '删除', iconCls: 'fa fa-minus-square fa-lg', onClick: function () {
  45. // $.yvan.msg('删除');
  46. // }
  47. // }, '-', {
  48. // text: '关闭', iconCls: 'fa fa-times-circle fa-lg', onClick: function () {
  49. // $.yvan.msg('关闭');
  50. // }
  51. // }
  52. //];
  53. return {
  54. north: {
  55. height: 120,
  56. items: [
  57. {
  58. xtype: 'button', text: '按钮1', onClick: function () {
  59. $grid.reset({
  60. multiselect: true,
  61. border: false,
  62. url: demoApi('/SysIdRule/query'),
  63. toolbar: toolbar,
  64. //shrinkToFit: true,
  65. //autoSizeColumns: false,
  66. idField: 'idName',
  67. columns: [[
  68. {field: 'idName', title: 'Id名称'},
  69. {field: 'idDesc', title: '描述'},
  70. {field: 'idType', title: '类型'},
  71. {field: 'seqType', title: '序列方法'},
  72. {field: 'seqType', title: '序列方法2', formatter: 'checkbox'},
  73. {field: 'idExpress', title: '表达式'},
  74. {field: 'createAt', title: '建立时间', formatter: 'ts'},
  75. {field: 'updateAt', title: '更新时间', formatter: 'ts'}
  76. ]]
  77. });
  78. }
  79. },
  80. {
  81. xtype: 'button', text: '按钮2', onClick: function () {
  82. $grid.reset({
  83. url: demoApi('/sysRole/query'),
  84. ff: 500,
  85. idField: 'roleId',
  86. columns: [[
  87. {field: 'roleId', hidden: true},
  88. {field: 'roleCode', title: '角色编号'},
  89. {field: 'roleName', title: '角色名称'},
  90. {field: 'categories', title: '角色分类', formatter: {E: '企业', A: '管理员', N: '仓库'}},
  91. {field: 'roleDes', title: '角色描述'},
  92. {field: 'beActive', title: '启用状态', formatter: 'beAction'},
  93. {field: 'createAt', title: '新增时间', formatter: 'ts'},
  94. {field: 'updateAt', title: '更新时间', formatter: 'ts'}
  95. ]]
  96. });
  97. }
  98. }
  99. ]
  100. },
  101. west: {
  102. border: false,
  103. width: '50%',
  104. split: true,
  105. items: {
  106. onRender: function () {
  107. $grid = $(this);
  108. },
  109. xtype: 'grid',
  110. toolbar: toolbar,
  111. pagination: true
  112. }
  113. },
  114. center: {
  115. border: false,
  116. items: {
  117. xtype: 'grid',
  118. border: false,
  119. //url: '/mock/id.json',
  120. url: demoApi('/SysIdRule/query'),
  121. idField: 'idName',
  122. toolbar: toolbar,
  123. columns: [
  124. [
  125. {field: 'idName', title: 'Id名称', width: 120},
  126. {field: 'idDesc', title: '描述', width: 130},
  127. {field: 'idType', title: '类型', width: 80},
  128. {field: 'seqType', title: '序列方法', width: 100},
  129. {field: 'idExpress', title: '表达式', width: 240},
  130. {field: 'createAt', title: '建立时间', width: 130, formatter: fmtDate},
  131. {field: 'updateAt', title: '更新时间', width: 130, formatter: fmtDate}
  132. ]]
  133. }
  134. }
  135. };
  136. };
  137. });