poiMapping.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /**
  2. * admin/poiMapping
  3. */
  4. var mcare_admin_poiMapping = function(){
  5. //상속
  6. mcare_admin.call(this);
  7. var self = this;
  8. //변수
  9. var $grid = $("#grid"),
  10. $crudServiceBaseUrl = contextPath + "/admin/poi";
  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: "poiSeq",
  71. fields: {
  72. poiSeq: {type:"number", editable:false},
  73. legacyName: { type: "string", nullable: false, validation: { required: true }},
  74. mapName: { type: "string"},
  75. mappingDesc: { type: "string"},
  76. useYn : {type:"string",defaultValue:"N"}
  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: "poiSeq",hidden:true, title: "시퀀스", width: 20, attributes: {style: "text-align: center;"}}
  121. ,{ field: "legacyName", title: "기간계", width: 180, attributes: {style: "text-align: center;"}}
  122. ,{ field: "mapName", title: "지도", width: 140, attributes: {style: "text-align: center;"}}
  123. ,{ field: "mappingDesc", title: "설명", width: 110, attributes: {style: "text-align: center;"}}
  124. ,{ field: "useYn", title: "사용여부", width:50, editor:useYnEditor,attributes: {style: "text-align: center;"}}
  125. ,{ command: [{name:"edit",text:"수정"},{name:"destroy",text:"삭제"}], title: " ", width: 100, attributes: {style: "text-align: center;"}}
  126. ],
  127. editable: "inline",
  128. edit: function(e) {
  129. if (!e.model.isNew()) {
  130. }
  131. },
  132. filterable: {
  133. extra : false,
  134. operators : {
  135. string : {
  136. contains : " 포함 "
  137. }
  138. }
  139. },
  140. dataBound: function () {
  141. var rowCount = $grid.find( ".k-grid-content tbody tr" ).length;
  142. if( rowCount < dataSource._take ) {
  143. var addRows = dataSource._take - rowCount;
  144. for( var i = 0; i < addRows; i++ ) {
  145. $grid.find( ".k-grid-content tbody" )
  146. .append( "<tr class='kendo-data-row'><td>&nbsp;</td></tr>" );
  147. }
  148. }
  149. }
  150. };
  151. function useYnEditor(container,options){
  152. var select = $("<select></select>").attr({"data-id":"useYnEditor","data-bind":"value:"+options.field});
  153. select.html("<option value='Y'>Y</option>");
  154. select.append("<option value='N'>N</option>");
  155. select.val(options.model.useYn).appendTo(container).kendoDropDownList({autoBind: false});
  156. }
  157. //그리드 초기화
  158. self.grid( $grid, option );
  159. };
  160. };