Index.cshtml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. @{
  2. ViewBag.Title = "换标操作";
  3. Layout = "~/Views/Shared/_Index.cshtml";
  4. }
  5. <style>
  6. .ui-jqgrid tr.jqgrow td {
  7. white-space: normal !important;
  8. height: auto;
  9. }
  10. </style>
  11. <script>
  12. $(document).ready(function () {
  13. initialPage();
  14. GetGrid();
  15. });
  16. //重设(表格)宽高
  17. function initialPage() {
  18. //resize重设(表格、树形)宽高
  19. $(window).resize(function (e) {
  20. window.setTimeout(function () {
  21. $('#gridTable').setGridWidth(($('.gridPanel').width()));
  22. $("#gridTable").setGridHeight($(window).height() - 108.5);
  23. }, 200);
  24. e.stopPropagation();
  25. });
  26. }
  27. //加载表格
  28. function GetGrid() {
  29. var selectedRowIndex = 0;
  30. var $gridTable = $('#gridTable');
  31. $gridTable.jqGrid({
  32. url: "/NBManage/NBCommandHis/GetCmdHis?id=" + @ViewBag.id + "&cmdType="+@ViewBag.cmdType,
  33. datatype: "json",
  34. height: $(window).height() - 108.5,
  35. autowidth: true,
  36. colModel: [
  37. { label: '命令ID', name: 'CmdID', width: 300, align: "left", sortable: false },
  38. { label: '发送时间', name: 'SendTime',width: 150, align: "left", sortable: false },
  39. { label: "更新时间", name: "RecvTime", width: 150, align: "left", sortable: false },
  40. { label: "发送报文", name: "SendText", width: 450, align: "left", sortable: false ,
  41. formatter: function (cellvalue, options, rowObject) {
  42. return JSON.stringify($.parseJSON(cellvalue).command)
  43. }
  44. },
  45. { label: "命令状态", name: "CmdResult", width: 100, align: "left", sortable: false },
  46. { label: "响应内容", name: "ReturnText", width: 100, align: "left", sortable: false }
  47. ],
  48. viewrecords: true,
  49. rowNum: 10,
  50. rowList: [5,10,15,20,30, 50, 100],
  51. pager: "#gridPager",
  52. gridview: true,
  53. rownumbers: true
  54. });
  55. }
  56. </script>
  57. <div class="gridPanel">
  58. <table id="gridTable"></table>
  59. <div id="gridPager"></div>
  60. </div>