telNo.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /**
  2. * admin/telNo
  3. */
  4. var mcare_admin_telNo = function(){
  5. //상속
  6. mcare_admin.call(this);
  7. var self = this;
  8. //변수
  9. var $grid = $("#grid"),
  10. $crudServiceBaseUrl = contextPath + "/admin/telno";
  11. /**
  12. * 초기화
  13. */
  14. this.init = function(){
  15. initGrid();
  16. addEvent();
  17. };
  18. /**
  19. * 이벤트 등록
  20. */
  21. var addEvent = function(){
  22. };
  23. // 데이터소스
  24. var dataSource = new kendo.data.DataSource({
  25. transport: {
  26. read: {
  27. url: $crudServiceBaseUrl + "/getList.json",
  28. method: "POST",
  29. dataType: "json",
  30. contentType: "application/json",
  31. complete: gridReadComplete
  32. },
  33. create: {
  34. url: $crudServiceBaseUrl + "/save.json",
  35. method: "post",
  36. dataType: "json",
  37. contentType: "application/json",
  38. complete: gridActionComplete
  39. },
  40. update: {
  41. url: $crudServiceBaseUrl + "/update.json",
  42. method: "post",
  43. dataType: "json",
  44. contentType: "application/json",
  45. complete: gridActionComplete
  46. },
  47. destroy: {
  48. url: $crudServiceBaseUrl + "/remove.json",
  49. method: "post",
  50. dataType: "json",
  51. contentType: "application/json",
  52. complete: gridActionComplete
  53. },
  54. parameterMap: function( options, operation ) {
  55. if( operation !== "read" && options.models ) {
  56. return self.util.stringifyJson( options.models[0] );
  57. } else if( operation === "read" ){
  58. return self.util.stringifyJson( options );
  59. }
  60. }
  61. },
  62. batch: true,
  63. pageSize: 14,
  64. serverPaging: true,
  65. serverSorting: true,
  66. schema: {
  67. data: "data",
  68. total: "totalCount",
  69. model: {
  70. id: "telnoSeq",
  71. fields: {
  72. telnoSeq: { type: "long", nullable: true,editable:false},
  73. buildingDesc: { type: "string", nullable: false, validation: { required: true }},
  74. roomDesc: { type: "string", nullable: true},
  75. telValue: { type: "string", nullable: false,validation: { required: true }},
  76. telnoOrder: { type: "number", nullable: true},
  77. }
  78. }
  79. }
  80. });
  81. /**
  82. * 그리드 이벤트 동작 complate
  83. * @private
  84. */
  85. function gridActionComplete( e ){
  86. var result = self.util.parseJson( e.responseText );
  87. if( result.msg )
  88. alert( result.msg );
  89. $grid.data("kendoGrid").dataSource.read();
  90. };
  91. /**
  92. * 그리드 이벤트 동작 complate
  93. * @private
  94. */
  95. function gridReadComplete( e ){
  96. var result = self.util.parseJson( e.responseText );
  97. if( result.msg ){
  98. alert( result.msg );
  99. if( result.type == "AuthException" ){
  100. window.location.href = contextPath + "/admin/logout.page";
  101. return;
  102. }
  103. }
  104. };
  105. /**
  106. * 그리드 초기화
  107. */
  108. var initGrid = function(){
  109. // 그리드 옵션
  110. var option = {
  111. dataSource: dataSource,
  112. pageable: true,
  113. sortable: true,
  114. resizable: true,
  115. height: 620,
  116. toolbar: [{ name : "create", text: "추가", complete: function(e) {
  117. $grid.data("kendoGrid").dataSource.read();
  118. } }],
  119. columns: [
  120. { field: "telnoSeq", title: "구분", width: 50, attributes: {style: "text-align: center;"}}
  121. ,{ field: "buildingDesc", title: "건물명", width: 120, attributes: {style: "text-align: center;"}}
  122. ,{ field: "roomDesc", title: "호수", width: 120, attributes: {style: "text-align: center;"}}
  123. ,{ field: "telnoOrder", title: "순서", width: 50, attributes: {style: "text-align: center;"}}
  124. ,{ field: "telValue", title: "전화번호", width: 150, attributes: {style: "text-align: center;"}}
  125. ,{ command: ["edit", "destroy"], title: " ", width: 120, attributes: {style: "text-align: center;"}}
  126. ],
  127. editable: "inline",
  128. edit: function(e) {
  129. if (!e.model.isNew()) {
  130. e.container.find( "input[name='telNoSeq']" ).attr("readonly", true);
  131. }
  132. },
  133. dataBound: function () {
  134. var rowCount = $grid.find( ".k-grid-content tbody tr" ).length;
  135. if( rowCount < dataSource._take ) {
  136. var addRows = dataSource._take - rowCount;
  137. for( var i = 0; i < addRows; i++ ) {
  138. $grid.find( ".k-grid-content tbody" )
  139. .append( "<tr class='kendo-data-row'><td>&nbsp;</td></tr>" );
  140. }
  141. }
  142. }
  143. };
  144. //그리드 초기화
  145. self.grid( $grid, option );
  146. };
  147. };