JSP·script·jquery

트리 만들기

초이짬 2013. 9. 24. 13:27
728x90

     <script type="text/javascript">
        <!--
        
        c = new dTree('c');
    
        
        c.add(0,-1,'코드 목록');
       
        <%
         int order = 0;
         List codeOneList = (List)request.getAttribute(oneCodeList");
         Map row = null;
         String nowID = "";
         String parentID = "";
         String codeNm = "";         
         String sort = "";
         String levl = "";
         String del = "";
         String newNm = "";
         String grup = "";
         int count=0;
         if ( codeOneList != null || ! codeOneList.isEmpty() ){
          for(int i = 0;i < codeOneList.size();i++){
           
           row = ut.getResultNullChk((Map)codeOneList.get(i));
           //row2 = ut.getResultNullChk((Map)codeTwoList.get(i));
           nowID = (String)row.get("CD_NO");
           parentID = (String)row.get("REF_CD_NO");           
           codeNm = (String)row.get("CD_NM");
           
           
           for(int l=0; l<codeNm.length(); l++){ // 이름에 '," 가 들어갈 경우 스크립트에서  전체 문자열을 인식하지 못하는 문제가 생김
            char ch = codeNm.charAt(l);
            
            if(ch == '\'' || ch == '\"'){
             newNm = newNm+"\\"+ch;
            }
            else if(ch == '\r' || ch == '\n'){
             newNm = newNm;
            }
            else{
             newNm = newNm+ch;
            }
           }
           if(newNm.length() > codeNm.length() && !codeNm.equals(newNm)) codeNm = newNm;            
           
           newNm = "";
           
           del = (String)row.get("DEL_YN");
           sort = (String)row.get("CD_SORT_ORDR");
           levl = (String)row.get("CD_CLSF_LEVL");
           grup = (String)row.get("GRUP_CD_NO");
           
           if(levl.equals("0")){
            order = 0;
           }
           else{
            if(order == 0) order = i;
            
           }
           %>
            c.add(<%=i+1 %>, <%=order %>, '<%=codeNm%>', "javascript:selectCode(document.code_form, '<%=nowID %>', '<%=codeNm%>', '<%=parentID %>', '<%=levl%>', '<%=sort%>', '<%=del%>', '<%=grup%>');", '<%=nowID%>', '<%=parentID%>');
           <% 
          }
         } 
         
        %>        

            
        document.write(c);
        //c.s(0);
        //c.closeAll();
        //-->
       </script>

728x90