FE개발팀
김동우
https://github.com/nhnent/fe.application-grid
Front-End Package Manager
$ npm install -g bower
Node.js - https://nodejs.org
Install
$ bower install ne-application-grid
$ cd bower_components
$ ls
backbone underscore
jquery-json jquery
ne-code-snippet ne-component-pagination
ne-application-grid
...
.btn_text,.btn_text span{display:inline-block;background:url(../images/bg_btn_text.gif) 0 0 no-repeat;color:#333;letter-spacing:-1px;text-decoration:none;white-space:nowrap;cursor:pointer}
.btn_text span{margin-left:8px;padding-right:7px;background-position:100% 0}
.btn_text:hover,.btn_text span:hover,.btn_text:focus,.btn_text span:focus{background-position:0 -30px}
.btn_text:active,.btn_text span:active{background-position:0 -60px}
.btn_text span:hover,.btn_text span:focus{margin-left:8px;padding-right:7px;background-position:100% -30px}
.btn_text span:active{margin-left:8px;padding-right:7px;background-position:100% -60px}
.btn_text .excel{display:inline-block;padding-left:17px;background:url(../images/sp_bu.gif) no-repeat 0 5px}
.btn_text .grid{display:inline-block;padding-left:17px;background:url(../images/sp_bu.gif) no-repeat 0 -21px}
.btn_text2,.btn_text2 span{display:inline-block;background:url(../images/bg_btn_text.gif) 0 -90px no-repeat;color:#444;letter-spacing:-1px;text-decoration:none;white-space:nowrap;cursor:pointer}
.btn_text2 span{margin-left:8px;padding-right:7px;background-position:100% -90px}
.btn_sp span{display:inline-block;overflow:hidden;width:74px;height:26px;background:url(../images/sp_btn.gif) no-repeat;cursor:pointer}
a span.del{width:55px;height:36px;background-position:-300px 0}
a:hover span.del,a:focus span.del{width:55px;height:36px;background-position:-380px 0}
a:active span.del{width:55px;height:36px;background-position:-460px 0}
...
...
<head>
...
<link rel="stylesheet" type="text/css" href="/css/grid.css" />
...
<script src="/js/lib/jquery.js"></script>
<script src="/js/lib/jquery.json.js"></script>
<script src="/js/lib/underscore.js"></script>
<script src="/js/lib/backbone.js"></script>
<script src="/js/lib/code-snippet.js"></script>
<script src="/js/lib/grid.js"></script>
...
</head>
<body>
...
<div id="grid"></div>
...
var grid = new ne.Grid ({
el
: $('#grid'),
// 그리드를 생성할 HTML 요소
headerHeight: 70,
// (default = 50) 헤더의 전체 높이 (pixel)
rowHeight : 30, // (default = 27) 한 Row의 높이 (pixel)
displayRowCount: 20, // (default = 10) 한번에 보여질 Row의 수
...
columnModelList
: [
... // Column 정보를 정의한 배열
],
toolbar: {
hasResizeHandler: false,
//
(default = true) 높이 조절 핸들러 표시 여부
hasControlPanel: false,
//
(default = true) 컨트롤 패널 표시 여부
hasPagination: false, // (default = true) 페이지네이션 사용 여부
}
});
grid. setRowList ([
... // 실제 데이터 (Row단위) 배열
]);
[
{
name: '전지현',
phone: '010-1234-xxxx',
age: 34,
birthday: '10/30',
company: 3,
job: '1,3',
popular: 1
},
{
name: '유아인',
phone: '010-3292-xxxx',
age: 26,
birthday: '07/25',
company: 5,
job: '1',
popular: 2
},
{
name: '스칼렛 요한슨',
phone: '010-3292-xxx',
age: 30,
birthday: '06/22',
company: 2,
job: '1,2,3',
popular: 1
},
{
name: '전도연',
phone: '010-9281-xxxx',
age: 30,
birthday: '07/22',
company: 3,
job: '1',
popular: 2
}
...
]
[
...
{
columnName: 'name', // 컬럼명, 데이터의 key값과 동일해야 함.
title: '이름', // 컬럼 헤더에 표시될 제목
align: 'center', // 정렬 방식: left, right, center
width: 100, // 컬럼 넓이
},
{
columnName: 'birthday',
title: '생일',
align: 'center',
width: 150,
editOption: {
type: 'text'
// normal, text, text-convertible, text-password, select, checkbox, radio
}
},
{
columnName: 'popular',
title: '인기도',
editOption: {
type: 'radio',
list: [ // type이 select, checkbox, radio 인 경우에만 정의
{text: '상', value: 1},
{text: '중', value: 2},
{text: '하', value: 3}
]
}
},
...
]
var grid = new ne.Grid({
el: $('#grid'),
displayRowCount: 20,
columnModelList: [
{
title: '이름',
columnName: 'name',
align: 'center',
},
{
title: '생일',
columnName: 'birthday',
editOption: {
type: 'text'
}
},
{
title: '나이',
columnName: 'age',
align: 'center',
editOption: {
type: 'text-convertible'
}
},
{
title: '전화번호',
columnName: 'phone',
editOption: {
type: 'text-password'
}
}
],
toolbar: {
hasResizeHandler: false,
hasControlPanel: false,
hasPagination: false
}
});
$.getJSON('/sample', function (result) {
grid.setRowList(result);
});
var grid = new ne.Grid({
el: $('#grid'),
displayRowCount: 20,
headerHeight: 60,
columnModelList: [
{
title: '이름',
columnName: 'name',
align: 'center',
width: 100,
},
{
title: '생일',
columnName: 'birthday',
align: 'center',
width: 100
},
{
title: '나이',
columnName: 'age',
width: 100,
isSortable: true,
align: 'center',
editOption: {
type: 'text-convertible'
}
},
{
title: '전화번호',
columnName: 'phone',
width: 200,
editOption: {
type: 'text-password'
},
},
{
title: '직업',
columnName: 'job',
width: 200,
editOption: {
type: 'checkbox',
list: [
{text: '배우', value: 1},
{text: '가수', value: 2},
{text: '모델', value: 3}
]
}
},
{
title: '인기도',
columnName: 'popular',
editOption: {
type: 'radio',
list: [
{text: '상', value: 1},
{text: '중', value: 2},
{text: '하', value: 3}
]
}
}
],
toolbar: {
hasResizeHandler: false,
hasControlPanel: false,
hasPagination: false
}
});
$.getJSON('/sample', function (result) {
grid.setRowList(result);
});
var grid = new ne.Grid({
el: $('#grid'),
headerHeight: 40,
displayRowCount: 20,
columnModelList: [
{
title: '번호',
columnName: '_number',
width: 50,
align: 'center'
},
{
title: '이름',
columnName: 'name',
width: 150,
align: 'center'
},
{
title: '나이',
columnName: 'age',
width: 100,
align: 'center',
editOption: {
type: 'text-convertible',
afterContent: ' 살'
}
},
{
title: '검색',
columnName: 'search',
width: 120,
align: 'center',
formatter: function(value, row) {
var searchUrl = 'http://search.naver.com/search.naver?ie=utf8&sm=stp_hty&where=se&query=' + row.name;
return '<a target="_blank" href="' + searchUrl + '">검색</a>';
}
},
{
title: '성별',
columnName: 'sex',
width: 100,
align: 'center',
editOption: {
type: 'select',
list: [
{text: '남', value:'M'},
{text: '여', value:'F'},
]
},
relationList: [
{
columnList: ['company'],
optionListChange: function(value) {
if (value === 'F') {
return [
{text: '천상계', value: 1},
{text: '내 영혼', value: 2},
{text: '내 마음', value: 3},
{text: '내 바탕화면', value: 4}
];
} else {
return [
{text: '관심없음', value: 5}
];
}
}
},
{
columnList: ['popular'],
isDisabled: function(value) {
return value === 'M';
}
}
]
},
{
title: '소속',
columnName: 'company',
width: 200,
editOption: {
type: 'select',
list: [
{text: '천상계', value: 1},
{text: '내 영혼', value: 2},
{text: '내 마음', value: 3},
{text: '내 바탕화면', value: 4},
{text: '관심없음', value: 5}
]
}
},
{
title: '인기도',
columnName: 'popular',
editOption: {
type: 'radio',
list: [
{text: '상', value: 1},
{text: '중', value: 2},
{text: '하', value: 3}
]
}
}
],
toolbar: {
hasResizeHandler: false,
hasControlPanel: false,
hasPagination: false
}
});
$.getJSON('/sample', function (result) {
grid.setRowList(result);
});
1.0.0 - 2015.05
1.0.3 - 2015.08
1.0.2 - 2015.07
1.0.1 - 2015.06