본문 바로가기

jQuery/w2ui

[w2ui] w2ui 설정하기

반응형

※ 해당 포스팅의 w2ui 설정에 사용된 *js, *.css 파일 버전

 -. jquery-2.1.0.min.js

 -. w2ui-1.4.3.js

 -. w2ui-1.4.3.css





01. http://w2ui.com/web/home 사이트에 접속해서 w2ui 사용에 필요한 *.js, *.css 파일을 다운받는다.





02. 다운받은 w2ui-1.4.3.zip 파일의 압축을 해제하고 아래 순서대로 작업을 수행한다.

 ① js폴더를 만들고 압축해제한 w2ui-1.4.3.js, w2ui-1.4.3.min.js 파일을 js폴더로 이동시킨다.

 ② css폴더를 만들고 압축해제한 w2ui-1.4.3.css, w2ui-1.4.3.min.css 파일을 css폴더로 이동시킨다.






03. jQuery도 준비를 해야 하는데 jQuery는 가능하면 w2ui 데모에서 지원하는 버전을 사용한는 것을 권장한다.

    w2ui의 DEMO(http://w2ui.com/web/demos/#!layout/layout-1) 페이지에 접속하여 사용중인 js버전을 확인하도록 하자.

※ 가장 최신버전의 jQuery 3.1.0 버전으로 사용하였을때 몇몇기능에서 정상적인 작동이 이루어지지 않았다.





04. js버전을 확인했다면. https://code.jquery.com/jquery/ 페이지에 접속하여 해당버전의 *.js 파일을 생성한다.

 ① minified 를 클릭한다.

 ② Code Integration 이라고 팝업창이 뜨면 해당 jQuery의 URL을 복사한다.





05. 04번의 ②번에서 복사한 페이지로 이동하고 표시되는 모든 내용을 복사한다.





06. 메모장등의 TEXT 편집기에 05번에서 복사한 내용을 붙여놓고 jquery-2.1.0.min.js 파일로 만들어서 저장한다.





07. 생성한 jquery-2.1.0.min.js 파일을 위에서 생성한 js파일과 같이 묶어준다.





08. 설정이 완료되었으면 이제 아래와같은 *.php 파일을 생성하여 정상적으로 w2ui가 나타나는지 확인해 보자.

 w2ui_test.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:500px;"></div>
<script type="text/javascript">
jQuery(function () {
    jQuery("#grid").w2grid({
          name : "grid"
        , columns : [               
            { field : "fname", caption : "Full Name", size : "200px", render : function(record, index, column_index) {
                var html = "<div>"+ record.fname + "&nbsp;" + record.lname + "</div>";
                    return html;
                }
            }
            , { field : "email", caption : "Email", size : "100%" }
            , { field : "profit", caption : "Profit", size : "120px", render : "money" }
            , { field : "sdate", caption : "Start Date", size : "120px", render : "date" }
        ]
        , records: [
              { recid : 1, fname : "John", lname : "Doe", email : "john@gmail.com", profit : 2500, sdate : "1/3/2012" }
            , { recid : 2, fname : "Stuart", lname : "Motzart", email : "stuart@gmail.com", profit : 1004, sdate : "4/13/2012" }
            , { recid : 3, fname : "Jin", lname : "Franson", email : "jin@gmail.com", profit : 473, sdate : "3/3/2012" }
            , { recid : 4, fname : "Susan", lname : "Ottie", email : "susan@gmail.com", profit : 304, sdate : "5/3/2012" }
            , { recid : 5, fname : "Kelly", lname : "Silver", email : "kelly@gmail.com", profit : 9300, sdate : "8/19/2012" }
            , { recid : 6, fname : "Francis", lname : "Gatos", email : "francis@gmail.com", sdate : "6/12/2012" }
            , { recid : 7, fname : "Mark", lname : "Welldo", email : "mark@gmail.com", profit : 3400, sdate : "8/13/2012" }
            , { recid : 8, fname : "Thomas", lname : "Bahh", email : "thomas@gmail.com", profit : 2030, sdate : "4/31/2012" }
            , { recid : 10, fname : "John", lname : "Doe", email : "john@gmail.com", profit : 13004, sdate : "1/3/2012" }
            , { recid : 12, fname : "Stuart", lname : "Motzart", email : "stuart@gmail.com", sdate : "4/13/2012" }
            , { recid : 13, fname : "Jin", lname : "Franson", email : "jin@gmail.com", profit : 4043, sdate : "3/3/2012" }
            , { recid : 14, fname : "Susan", lname : "Ottie", email : "susan@gmail.com", profit : 474, sdate : "5/3/2012" }
            , { recid : 15, fname : "Kelly", lname : "Silver", email : "kelly@gmail.com", profit : 1704, sdate : "8/19/2012" }
            , { recid : 16, fname : "Francis", lname : "Gatos", email : "francis@gmail.com", sdate : "6/12/2012" }
            , { recid : 17, fname : "Mark", lname : "Welldo", email : "mark@gmail.com", profit : 7065, sdate : "8/13/2012" }
            , { recid : 18, fname : "Thomas", lname : "Bahh", email : "thomas@gmail.com", profit : 609, sdate : "4/31/2012" }
            , { recid : 19, fname : "Sergei", lname : "Rachmaninov", email : "sergei@gmail.com", profit : 777, sdate : "2/23/2012" }
        ]
    });   
});
</script>
</body>
</html>





09. 이제 해당 w2ui_test.php 파일을 실행시키면 아래와같은 출력결과가 나타는것을 알 수 있다.


반응형