-------------------------- grid -------------------------------

/* grid */
  jQuery("#list").jqGrid({
   url : selectUrl + "?" + $("#listForm").serialize(),
   mtype : 'POST',
   datatype : "local",
   postData : {LISTOP:$("#LISTOP").val()},
   page : "${LISTOP.ht.miv_pageNo}",
   rowNum : "${LISTOP.ht.miv_pageSize}",
   colNames : varColnames,
   colModel : [
                {name : 'rnum',           index : 'rnum',          width : 5,  align : "center",  hidden:false, sortable:false},
                {name : 'etesttext',    index : 'etesttext',     width : 50,  align : "left",   hidden:false,   formatter:jsSvrDetailFormmater},
                {name : 'levels',        index : 'levels',        width : 5,  align : "center",  hidden:true},
                {name : 'levels_nm',      index : 'levels_nm',     width : 10,  align : "center",  hidden:false},
                {name : 'etestdiv_nm',    index : 'etestdiv_nm',     width : 10,  align : "center",  hidden:false},               
                {name : 'etesttype',    index : 'etesttype',     width : 5,  align : "center",  hidden:true},
                {name : 'etesttype_nm',   index : 'etesttype_nm',  width : 10,  align : "center",  hidden:false},
                {name : 'ldate',          index : 'ldate',         width : 18,  align : "center",  hidden:true},
                {name : 'etestsubj',      index : 'etestsubj',     width : 18,  align : "center",  hidden:true},
                {name : 'etestnum',       index : 'etestnum',      width : 10,  align : "center",  hidden:false},
                {name : 'preview',        index : 'preview',       width : 10,  align : "center",  hidden:false, sortable:false},
                {name : 'grcode',         index : 'grcode',        width : 10,  align : "center",  hidden:true},
                {name : 'testid',         index : 'testid',        width : 10,  align : "center",  hidden:true},
                {name : 'etestpaper_cnt', index : 'etestpaper_cnt',width : 10,  align : "center",  hidden:true},

                {name : 'date',        index : 'date',         width : 10,     align : "center",   hidden:false,  formatter:jsShortDateFormmater},

                {name : 'stat',           index : 'stat',            width : 5,         align : "center",        hidden:false,  

                         formatter : function(value, options, rData) {
                                    if(value == "Y"){
                                           return '<g:label code="tlms_etestresult.completed" desc="완료"/>';
                                    }else{
                                          return '<g:label code="frt.idp.incomplete" desc="미완료"/>'; 
                                   }
                          }
                }
              ],
   pager : '#pager',
   sortname : 'testid',
   scrollrows : true,
   viewrecords : true,
   sortorder : "desc",
   height : "350",
      autowidth : true,
      multiselect : true,   //select box
            jsonReader: {
                page: "page",
                total: "total",
                root: "rows",
                id: "mgmnt",
                records: "records",
                repeatitems: false,
                cell: "cell"
            },
   gridComplete : function() {
                 //Grid 안에 버튼넣기
                var ids = jQuery("#list").jqGrid('getDataIDs');
                for(var i = 0 ; i < ids.length ; i++) {
                 var cl = ids[i];
                 var rowdata = $("#list").getRowData(ids[i]);
                 
                 rowdata.etesttext = $(rowdata.etesttext).text();
                 var jsonText = JSON.stringify(rowdata).replace(/\"/gi, "'");
                 
                 var bt1 = '<g:btn href="javascript:jsPreViewPage('+jsonText+');" type="btnC" msg="com.preview" />';
                 jQuery("#list").jqGrid('setRowData', ids[i], {preview : bt1});
                   
                }
   },
            loadComplete: function (jsondata) {
             // store curent search option at LISTOP
             $("#LISTOP").val(jsondata.LISTOPVALUE);
            }           
  });
  $("#list").jqGrid('navGrid', '#pager', {
   edit : false,
   add : false,
   del : false,
   search : false,
   refresh : false
  });

 

/* site name detail link fommatter */
 function jsSvrDetailFormmater(cellvalue, options, rowObject) {

  if(rowObject.etestcode=="" || rowObject.etestcode==null){
   return cellvalue;
  }else{
   var jsonText = JSON.stringify(rowObject).replace(/\"/gi, "'");
      return '<a href="javascript:jsDetailPage('+jsonText+');"><Strong><u>' + cellvalue + '<u></Strong></a>';
      
  }
 }

 

------------------------ 삭제시 ---------------------------

/* all data delete */
 function deleteAll() {
  
  var totCount = $("#list").getGridParam("records");
  
  if( totCount > 0 ) {
   
   if(confirm("<g:message code='MESSAGE.idp_msg_text.delete_confirm' />")) {
   
    $.ajax({
              type: "POST",
              url: deleteAllUrl,
              data: $("#listForm").serialize(), 
              dataType: "json",
              success: function(data) {
                  if(data.success == "true") {
                   alert(data.message);
                   $("#btn_search").trigger('click');
                  }else if(data.success == "false") {
                   //시험지에 출제된 문제는 삭제할수 없습니다.
                   alert("<g:message code='MESSAGE.tlms_etest.ques_delete_error' />");
                  }else if(data.success == "err") {
                   //삭제되지 않았습니다.
                   alert("<g:message code='MESSAGE.frt.lms.stream.notDel' />");
                  }
              }
          });
   }
   
  }
  
 }
 
 /* selected data delete */
 function deleteSelected() {
  
  var select_data = $("#list").getArrayFromMultiSelectedRow();

        if ( select_data.length == 0 ) {
            alert("<g:message code='MESSAGE.idp_msg_text.selectmember' desc='대상자를 선택하세요.'/>");
            return;
        }
        
        var params = new Array();  
  var id  = $("#list").getGridParam('selarrrow');
  var ids = $("#list").jqGrid('getDataIDs');
  for (var i = 0; i < ids.length; i++) {
            var check = false;
            $.each(id, function (index, value) {             
                if (value == ids[i]){
                    check = true;
             }
            });
           
            if (check) {             
                var rowdata = $("#list").getRowData(ids[i]);
               
                var obj = new Object();
       obj.testid    = rowdata.testid;
       obj.grcode    = rowdata.grcode;
       obj.etestnum  = rowdata.etestnum;
       obj.etestsubj = rowdata.etestsubj;
       params.push(obj);
            }
        }
  
  if(confirm("<g:message code='MESSAGE.idp_msg_text.delete_confirm' />")) {
  
   $.ajax({
             type: "POST",
             url: deleteSeletedUrl,
             data: {id_size:params.length,data: params}, 
             dataType: "json",
             success: function(data) {
                 if(data.success == "true") {
                  alert(data.message);
                  $("#btn_search").trigger('click');
                 }else if(data.success == "false") {
                  //시험지에 출제된 문제는 삭제할수 없습니다.
                  alert("<g:message code='MESSAGE.tlms_etest.ques_delete_error' />");
                 }else if(data.success == "err") {
                  //삭제되지 않았습니다.
                  alert("<g:message code='MESSAGE.frt.lms.stream.notDel' />");
                 }
             }
         });
  }
  
 }

--- java param value setting ---

/* all data delete */
Map<String, Object> param = new HashMap<String, Object>();
param = _req.getParameterMap();

 /* selected data delete */
Map<String, Object> param = _req.getParameterMap();
param.put( "srch_testid",    String.valueOf(param.get("data["+i+"][testid]")) );
param.put( "srch_grcode",    String.valueOf(param.get("data["+i+"][grcode]")) );
param.put( "srch_etestnum",  String.valueOf(param.get("data["+i+"][etestnum]")) );
param.put( "srch_etestsubj", String.valueOf(param.get("data["+i+"][etestsubj]")) );

int idCount = NumberUtils.toInt(String.valueOf(param.get("id_size")));

 

 

 

 

'JavaScript > Jquery' 카테고리의 다른 글

[jQuery] jqGrid 조회  (0) 2012.10.26
[jQuery] jquery 명령어  (0) 2012.10.26
[Jquery] jqgrid 참고 Url  (0) 2012.09.14
[jQuery] jQuery API   (0) 2012.03.29
[JQuery] 정리 잘 된 사이트  (0) 2012.02.08

+ Recent posts