Index.cshtml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. @{
  2. ViewBag.Title = "Index";
  3. Layout = "~/Views/Shared/_Index.cshtml";
  4. }
  5. <script>
  6. $(function () {
  7. InitialPage();
  8. GetGrid();
  9. //表格表头居中显示
  10. $(".ui-th-column").css("text-align", "center");
  11. });
  12. //初始化页面
  13. function InitialPage() {
  14. //resize重设(表格、树形)宽高
  15. $(window).resize(function (e) {
  16. window.setTimeout(function () {
  17. $('#gridTable').setGridWidth(($('.gridPanel').width()));
  18. $("#gridTable").setGridHeight($(window).height() - 141);
  19. $("#itemTree").setTreeHeight($(window).height() - 52);
  20. }, 200);
  21. e.stopPropagation();
  22. });
  23. }
  24. function GetGrid() {
  25. var selectedRowIndex = 0;
  26. var $gridTable = $('#gridTable');
  27. $gridTable.jqGrid({
  28. url: "/NBManage/NBDevManufacturerCodeManage/GetNBDevManufacturerCode",
  29. datatype: "json",
  30. height: $(window).height() - 138.5,
  31. autowidth: true,
  32. rownumbers: true,
  33. colModel: [
  34. { label: "编号", name: "NBDevManufacturerCodeID", width: 100, align: "right", sortable: false },
  35. { label: "设备厂商ID", name: "NBDevManufacturerCodeName", width: 150, align: "left", sortable: false }
  36. ],
  37. viewrecords: true,
  38. rowNum: 30,
  39. rowList: [30, 50, 100],
  40. pager: "#gridPager",
  41. gridview: true,
  42. onSelectRow: function () {
  43. selectedRowIndex = $("#" + this.id).getGridParam('selrow');
  44. },
  45. gridComplete: function () {
  46. $("#" + this.id).setSelection(selectedRowIndex, false);
  47. }
  48. });
  49. //查询事件
  50. $("#btn_Search").click(function () {
  51. var keyword=$("#txt_Keyword").val()
  52. $gridTable.jqGrid('setGridParam', {
  53. postData: { queryJson: keyword },
  54. page: 1
  55. }).trigger('reloadGrid');
  56. });
  57. //查询回车
  58. $('#txt_Keyword').bind('keypress', function (event) {
  59. if (event.keyCode == "13") {
  60. $('#btn_Search').trigger("click");
  61. }
  62. });
  63. }
  64. //新增
  65. function btn_add() {
  66. dialogOpen({
  67. id: "Form",
  68. title: '添加表具类型',
  69. url: '/NBManage/NBDevManufacturerCodeManage/Form',
  70. width: "750px",
  71. height: "350px",
  72. callBack: function (iframeId) {
  73. top.frames[iframeId].AcceptClick();
  74. }
  75. });
  76. };
  77. //编辑
  78. function btn_edit() {
  79. var keyValue = $("#gridTable").jqGridRowValue("NBDevManufacturerCodeID");
  80. if (checkedRow(keyValue)) {
  81. dialogOpen({
  82. id: "Form",
  83. title: '修改表具类型',
  84. url: '/NBManage/NBDevManufacturerCodeManage/Form?keyValue=' + keyValue,
  85. width: "750px",
  86. height: "500px",
  87. callBack: function (iframeId) {
  88. top.frames[iframeId].AcceptClick();
  89. }
  90. });
  91. }
  92. }
  93. //删除
  94. function btn_delete() {
  95. var keyValue = $("#gridTable").jqGridRowValue("NBDevManufacturerCodeID");
  96. if (keyValue) {
  97. $.RemoveForm({
  98. url: "/NBManage/NBDevManufacturerCodeManage/DeleteForm",
  99. param: { keyValue: keyValue },
  100. success: function (data) {
  101. $("#gridTable").resetSelection();
  102. $("#gridTable").trigger("reloadGrid");
  103. }
  104. })
  105. } else {
  106. dialogMsg('请选择需要删除的数据项!', 0);
  107. }
  108. }
  109. </script>
  110. <div class="titlePanel">
  111. <div class="title-search">
  112. <table>
  113. <tr>
  114. <td>
  115. <div id="queryCondition" >
  116. <a class="btn btn-default dropdown-text" data-toggle="dropdown">类型名称</a>
  117. </div>
  118. </td>
  119. <td style="padding-left: 2px;">
  120. <input id="txt_Keyword" type="text" class="form-control" placeholder="请输入要查询关键字" style="width: 200px;" />
  121. </td>
  122. <td style="padding-left: 5px;">
  123. <a id="btn_Search" class="btn btn-primary"><i class="fa fa-search"></i>&nbsp;查询</a>
  124. </td>
  125. </tr>
  126. </table>
  127. </div>
  128. <div class="toolbar">
  129. <div class="btn-group">
  130. <a id="lr-replace" class="btn btn-default" onclick="reload();"><i class="fa fa-refresh"></i>&nbsp;刷新</a>
  131. <a id="lr-add" class="btn btn-default" onclick="btn_add()"><i class="fa fa-plus"></i>&nbsp;新增</a>
  132. <a id="lr-edit" class="btn btn-default" onclick="btn_edit()"><i class="fa fa-pencil-square-o"></i>&nbsp;编辑</a>
  133. <a id="lr-delete" class="btn btn-default" onclick="btn_delete()"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
  134. </div>
  135. </div>
  136. </div>
  137. <div class="gridPanel">
  138. <table id="gridTable"></table>
  139. <div id="gridPager"></div>
  140. </div>