cdnjs 에서 gridstack으로 최신 버젼 검색 추천
문서가 엉터리란 나의 생각은 3시간 뒤 나의 오타가 일으킨 불발탄임을 알았당.
일단 gridStack 1개짜리 기본 샘플을 보장!
gridBasicSample.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>E7E GridStack.js</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/9.1.1/gridstack.min.css" />
<!-- column 갯수 제한 할 땐 아래 꺼도 피로-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/9.1.1/gridstack-extra.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/9.1.1/gridstack-all.min.js"></script>
<style>
#wrapper {
width: 70vw;
height: 60vh;
}
.grid-stack {
background: #FAFAD2;
}
.grid-stack-item-content {
background-color: #18BC9C;
}
.trash {
height: 100%;
border: 1px solid black;
background: rgba(255, 0, 0, 0.1) center center url(data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjY0cHgiIGhlaWdodD0iNjRweCIgdmlld0JveD0iMCA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nPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+CjxnPgo8L2c+Cjwvc3ZnPgo=) no-repeat;
}
#dleft,
#dright {
display: inline-block;
vertical-align: top;
}
#dleft {
width: 70%;
}
#dright {
width: 25%;
}
</style>
</head>
<body>
<div id="wrapper">
<div class="grid-stack" id="dleft"></div>
<div class="trash" id="dright">휴지통</div>
<div><button onclick="fcompact()">컴팩트</button></div>
</div>
<script>
// using serialize data instead of .addWidget()
let items = [
{ x: 0, y: 0, w: 2, h: 2, content: 'item 1' },
{ x: 3, y: 0, w: 4, h: 2, content: 'item 2' },
{ x: 2, y: 3, w: 3, content: 'item 3' },
{ x: 1, y: 3, content: 'item 4' }
];
//확장 (jQuery Plugin 느낌!)
GridStack.prototype.e7eMerong = function () {
console.log("GridStack", this);
}
// const grid = GridStack.init(); // 옵션 없이 생성
let gridOption = {
column: 6, // default 12
oneColumnSize: 100, // default 768
minRow: 1,
disableOneColumnMode: true,
margin: 1,
placeholderText: '언제 보여용,아! 움직일 땡',
disableResize: true,
//float: true,
removable: '.trash',
//cellHeight: 50,
//cellWidth: 50,
// 한줄 혼자 꽉 채우는 거 금지!,default value of oneColumnSize is 768px
disableOneColumnMode: true,
resizable: { handles: 'e,se,s,sw,w' }
}
// const grid = GridStack.init(); // 옵션 없이 생성(Default)
let grid = GridStack.init(gridOption);
grid.load(items);
grid.addWidget({ w: 2, content: "직접 추강" });
grid.e7eMerong();
// 컴팩트
function fcompact() {
grid.compact();
}
</script>
</body>
</html>
실행 결과와 코드를 매칭시켜 느낌을 받도록 해야 함! (오타만 없으면 느낌 쫘악 옴!)
그리도 여러개 사용할 때 봐 둬야 할 코드
let grids = GridStack.initAll(options);
GridStack.setupDragIn('.sidebar .grid-stack-item', { appendTo: 'body', helper: myClone });
grids.forEach(function (grid, i) {
grid.load(items);
});
// decide what the dropped item will be - for now just a clone but can be anything
function myClone(event) {
console.log("체킹!");
const el = event.target.cloneNode(true);
el.setAttribute('gs-id', 'foo'); // TEST why clone element is not used directly on drop #2231
return el;
}
grids[1].compact();
2개짜리 샘플은 모양 좀 있게 맹글어 보아야겠당.(담시 보륭)
All of Me
https://www.youtube.com/watch?v=450p7goxZqg
검색 드롭다운 원리 (Search Drop Down) (4) | 2023.11.06 |
---|---|
DHTMLX Gantt (1) | 2023.11.03 |
FullCalendar(풀캘린더) 어거지 사용법 (6) | 2023.09.06 |
브라우져에서 자바스크립트 Module 사용하당 (0) | 2023.09.06 |
차트 그려 보아용 (chart.js) (0) | 2023.09.04 |