본문 바로가기

jQuery/w2ui

[w2ui] 그리드(Grid) 열(Row) 클릭이벤트로 팝업창 오픈하기.

반응형

그리드 클릭이벤트



01. w2ui 그리드에서 해당 행을 클릭하였을 경우 팝업창이 오픈되게 수정하여보자.

     결과는는 아래와 같이 코드로 구성되어 있다.

 w2ui_grid_group.php

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>W2UI</title>
    <link rel="stylesheet" type="text/css" href="./css/w2ui-1.4.3.css"/>
    <script type="text/javascript" src="./js/jquery-2.1.0.min.js"></script>
    <script type="text/javascript" src="./js/w2ui-1.4.3.js"></script>
</head>
<body>
<div id="grid" style="width:100%;height:350px;"></div>
<script type="text/javascript">
jQuery(document).ready(function() {
    jQuery("#grid").w2grid({
          name : "grid"
        , columns : [               
              { field:"name", caption:"이름", size:"30%" }
            , { field:"autonym", caption:"본명", size:"30%" }
            , { field:"position", caption:"포지션", size:"40%" }
            , { field:"birthday", caption:"생일", size:"120px" }
        ]
        , records : [
              { recid:1, name:"나연", autonym:"임나연", position:"리드샌서, 리드보컬", birthday:"1995-09-22" }
            , { recid:2, name:"정연", autonym:"유정연", position:"리드보컬", birthday:"1966-11-01" }
            , { recid:3, name:"모모", autonym:"히라이 모모", position:"서브보컬, 메인댄서", birthday:"1996-11-09" }
            , { recid:4, name:"사나", autonym:"미나토자키 사나", position:"서브보컬", birthday:"1996-12-29" }
            , { recid:5, name:"지효", autonym:"박지효", position:"리더, 메인보컬", birthday:"1997-02-01" }
            , { recid:6, name:"미나", autonym:"묘이 미나", position:"서브보컬, 메인댄서", birthday:"1997-03-24" }
            , { recid:7, name:"다현", autonym:"김다현", position:"리드래퍼, 서브보컬", birthday:"1998-05-28" }
            , { recid:8, name:"채영", autonym:"손채영", position:"메인래퍼, 서브보컬",  birthday:"1999-04-23" }
            , { recid:9, name:"쯔위", autonym:"저우 쯔위", position:"서브보컬, 리드댄서", birthday:"1999-06-14" }
        ]

        // , onClick : function(event) {       // 한번 클릭한 경우

        , onDblClick : function(event) {      // 더블 클릭한 경우
            var record = this.get(event.recid);
            w2popup.open({
                  width:550
                , height:320
                , title:"TWICE"
                , body:
                      "<div style='height:20px'></div>"
                    + "<div class='w2ui-field'>"
                    + "<label>이름 :</label>"
                    + "<div>"
                    + "<input type='text' maxlength='100' size='60' value='" + record.name + "'/>"
                    + "</div>"
                    + "</div>"
                    + "<div class='w2ui-field'>"
                    + "<label>본명 :</label>"
                    + "<div>"
                    + "<input type='text' maxlength='100' size='60' value='" + record.autonym + "'/>"
                    + "</div>"
                    + "</div>"
                    + "<div class='w2ui-field'>"
                    + "<label>생일 :</label>"
                    + "<div>"
                    + "<input type='text' maxlength='100' size='60' value='" + record.birthday + "'/>"
                    + "</div>"
                    + "</div>"
                    + "<div class='w2ui-field'>"
                    + "<label>포지션 :</label>"
                    + "<div>"
                    + "<textarea type='text' style='width:385px;height:80px;resize:none'>" + record.position + "</textarea>"
                    + "</div>"
                    + "</div>"
                , buttons:"<button class='btn' onClick='w2popup.close();'>Close</button>"
                , showMax:true
            });
        }
    });   
});
</script>
</body>
</html>



02. 출력결과는 아래와 같이 클릭시 팝업창이 오픈되는것을 확인 할 수 있다.


반응형