[jqgrid]체크한 리스트를 가져오는 2가지 방법
방법 1. if문
loadComplete: function() { var priceModiListPop = $("td[aria-describedby $= 'delCHK']"); priceModiListPop.click(function(){ var storerCdList = ""; for(var i=0;i<$("#gridCustPriList").getGridParam('reccount');i++){ if($("#gridCustPriList").getRowData()[i].delCHK == 'Y'){ if($("#gridCustPriList").getGridParam('reccount') == i+1){ storerCdList += $("#gridCustPriList").getRowData()[i].storerCd; } else { storerCdList += $("#gridCustPriList").getRowData()[i].storerCd + ","; } } } if(storerCdList[storerCdList.length-1] == ','){ storerCdList = storerCdList.substring(0,storerCdList.length-1); } // 파라미터 추가 var params = { 'storerCdList' : storerCdList}; deleteParams = JSON.stringify(params); }); } |
방법 2. 삼항연산자
loadComplete: function() { var priceModiListPop = $("td[aria-describedby $= 'delCHK']"); priceModiListPop.click(function(){ var delflag = false; var storerCdList = ""; var listData = $("#gridCustPriList").jqGrid('getRowData'); for(var index in listData){ var delyn = listData[index].delCHK; // 삭제 체크 여부 var storerCd = listData[index].storerCd; // storerCd 값
if(delyn === 'Y'){ delflag = true; storerCdList = (storerCdList === '') ? storerCd : storerCdList + ',' + storerCd; } } // 파라미터 추가 var params = { 'storerCdList' : storerCdList}; deleteParams = JSON.stringify(params); }); } |