sheet.outlineColumn.options({columnIndex: index}) 속성을 사용하여 데이터를 트리 보기로 표시합니다. 그룹 표시기를 클릭하면 열을 확장하거나 축소할 수 있습니다.
기본 제공 increaseCellIndent 및 decreaseCellIndent 명령을 사용하여 계층 데이터를 변경합니다.
Increase Cell Indent Command: 셀 들여쓰기 및 행 그룹 수준을 늘리려면 키보드 바로 가기 'ctrl-atl-]'를 사용합니다.
Decrease Cell Indent Command: 셀 들여쓰기 및 행 그룹 수준을 줄이려면 키보드 바로 가기 'ctrl-atl-['를 사용합니다. expandIndicator 또는 collapseIndicator 옵션을 사용하여 확장 및 축소 표시기를 사용자 정의합니다.
표시기를 확장 및 축소하려면 expandIndicator 또는 collapseIndicator 옵션을 사용합니다.
images 및 showImage 옵션을 사용하여 각 수준에 표시된 이미지를 사용자 정의할 수 있습니다.
showCheckBox 옵션을 사용하여 각 행의 확인란 표시 여부 상태를 사용자 정의합니다. 셀의 확인란을 선택하거나 해제하면 해당 하위 확인란의 상태도 모두 영향을 받습니다.
maxLevel 옵션을 사용하여 데이터 계층 수준을 제어할 수 있습니다. 기본 maxLevel은 10입니다.
<template>
<div class="sample-tutorial">
<gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread">
<gc-worksheet>
</gc-worksheet>
</gc-spread-sheets>
<div class="options-container">
<div class="options-row">
<label>OutlineColumn Options:</label>
</div>
<div class="options-row">
<input type="checkbox" id="showIndicator" v-model="showIndicator">
<label for="showIndicator" class="inlineLabel">Show Indicator</label>
</div>
<div class="options-row">
<input type="checkbox" id="showCheckBox" v-model="showCheckBox">
<label for="showIndicator" class="inlineLabel">Show CheckBox</label>
</div>
<div class="options-row">
<input type="checkbox" id="showImage" v-model="showImage">
<label for="showIndicator" class="inlineLabel">Show Image</label>
</div>
<div class="options-row">
<input type="checkbox" id="allowCustomIndicator" v-model="allowCustomIndicator">
<label for="showIndicator" class="inlineLabel">Allow Custom Indicator</label>
</div>
<div class="options-row">
<label for="maxLevel">Max Level:</label>
<input type="text" id="maxLevel" v-model="maxLevel">
</div>
<div class="options-row">
<input type="button" value="Set" @click="setMaxLevel()" />
</div>
<div class="options-row">
<label>Custom Image Settings:</label>
</div>
<div class="options-row">
<label for="image1">Label 1 image:</label>
<input type="file" @change="selectImage1" id="image1">
</div>
<div class="options-row">
<label for="image2">Label 2 image:</label>
<input type="file" @change="selectImage2" id="image2">
</div>
<div class="options-row">
<label for="image3">Label 3 image:</label>
<input type="file" @change="selectImage3" id="image3">
</div>
<div class="options-row">
<input type="button" value="Set" @click="setImages()">
</div>
<div class="options-row">
<label>Custom Indicator Image Settings:</label>
</div>
<div class="options-row">
<label for="indicator1">Expanded Image:</label>
<input type="file" @change="selectIndicator1" id="indicator1" :disabled="!allowCustomIndicator">
</div>
<div class="options-row">
<label for="indicator2">Collapsed Image:</label>
<input type="file" @change="selectIndicator2" id="indicator2" :disabled="!allowCustomIndicator">
</div>
<div class="options-row">
<input type="button" value="Set" @click="setCustomIndicator()" :disabled="!allowCustomIndicator">
</div>
</div>
</div>
</template>
<script setup>
import { ref, watch } from "vue";
import "@mescius/spread-sheets-vue";
import GC from '@mescius/spread-sheets';
import '@mescius/spread-sheets-resources-ko';
GC.Spread.Common.CultureManager.culture("ko-kr");
const spreadRef = ref(null);
const showIndicator = ref(true);
const showCheckBox = ref(true);
const showImage = ref(true);
const allowCustomIndicator = ref(true);
const maxLevel = ref(2);
const image1 = ref("/spreadjs/demos/spread/source/images/task-1.png");
const image2 = ref("/spreadjs/demos/spread/source/images/task-2.png");
const image3 = ref("/spreadjs/demos/spread/source/images/task-3.png");
const indicator1 = ref("/spreadjs/demos/spread/source/images/increaseIndicator.png");
const indicator2 = ref("/spreadjs/demos/spread/source/images/decreaseIndicator.png");
watch(showIndicator, (value) => {
let spread = spreadRef.value;
let sheet = spread.getActiveSheet();
sheet.outlineColumn.options().showIndicator = value;
sheet.outlineColumn.refresh();
});
watch(showCheckBox, (value) => {
let spread = spreadRef.value;
let sheet = spread.getActiveSheet();
sheet.outlineColumn.options().showCheckBox = value;
sheet.outlineColumn.refresh();
});
watch(showImage, (value) => {
let spread = spreadRef.value;
let sheet = spread.getActiveSheet();
sheet.outlineColumn.options().showImage = value;
sheet.outlineColumn.refresh();
});
watch(allowCustomIndicator, (value) => {
let spread = spreadRef.value;
let sheet = spread.getActiveSheet();
if (!value) {
sheet.outlineColumn.options().expandIndicator = null;
sheet.outlineColumn.options().collapseIndicator = null;
sheet.outlineColumn.refresh();
} else {
sheet.outlineColumn.options().expandIndicator = indicator1.value;
sheet.outlineColumn.options().collapseIndicator = indicator2.value;
sheet.outlineColumn.refresh();
}
});
let initSpread = function (spread) {
spreadRef.value = spread;
let sheet = spread.getActiveSheet();
sheet.suspendPaint();
loadData(sheet);
initOutlineColumn(sheet);
setOutlineColumnOptions(sheet);
sheet.getRange(0, 3, 25, 3).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
sheet.resumePaint();
}
function setCustomIndicator(){
let spread = spreadRef.value;
let sheet = spread.getActiveSheet();
sheet.outlineColumn.options().expandIndicator = indicator1.value;
sheet.outlineColumn.options().collapseIndicator = indicator2.value;
sheet.outlineColumn.refresh();
}
function setMaxLevel() {
let spread = spreadRef.value;
let sheet = spread.getActiveSheet();
sheet.outlineColumn.options().maxLevel = parseInt(maxLevel.value);
sheet.outlineColumn.refresh();
}
function setImages() {
let spread = spreadRef.value;
let sheet = spread.getActiveSheet();
sheet.outlineColumn.options().images = [
image1.value,
image2.value,
image3.value
];
sheet.outlineColumn.refresh();
}
function selectImage1(e) {
let file = e.target.files[0];
if (!/image\/\w+/.test(file.type)) {
alert('The file must be an image!');
return false;
}
let reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function (e) {
image1.value = this.result;
};
}
function selectImage2(e) {
let file = e.target.files[0];
if (!/image\/\w+/.test(file.type)) {
alert('The file must be an image!');
return false;
}
let reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function (e) {
image2.value = this.result;
};
}
function selectImage3(e) {
let file = e.target.files[0];
if (!/image\/\w+/.test(file.type)) {
alert('The file must be an image!');
return false;
}
let reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function (e) {
image3.value = this.result;
};
}
function selectIndicator1(e) {
let file = e.target.files[0];
if (!/image\/\w+/.test(file.type)) {
alert('The file must be an image!');
return false;
}
let reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function (e) {
indicator1.value = this.result;
};
}
function selectIndicator2(e) {
let file = e.target.files[0];
if (!/image\/\w+/.test(file.type)) {
alert('The file must be an image!');
return false;
}
let reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function (e) {
indicator2.value = this.result;
};
}
function loadData(sheet) {
let sd = data;
sheet.setDataSource(sd);
sheet.setColumnCount(6);
sheet.setColumnWidth(0, 150);
sheet.setColumnWidth(1, 350);
sheet.setColumnWidth(2, 150);
sheet.setColumnWidth(3, 150);
sheet.setColumnWidth(4, 150);
sheet.setColumnWidth(5, 150);
for (var r = 0; r < sd.length; r++) {
var level = sd[r].level;
if (level == 0) {
sheet.getRange(r, 0, 1, 7).backColor("#CCCCCC");
}
else if (level == 1) {
sheet.getRange(r, 0, 1, 7).backColor("#EEEEEE");
}
sheet.getCell(r, 0).textIndent(level);
}
}
function initOutlineColumn(sheet) {
sheet.outlineColumn.options({
columnIndex: 0,
showImage: true,
showCheckBox: true,
images: ['$DEMOROOT$/spread/source/images/task-1.png', '$DEMOROOT$/spread/source/images/task-2.png', '$DEMOROOT$/spread/source/images/task-3.png'],
expandIndicator: '$DEMOROOT$/spread/source/images/increaseIndicator.png',
collapseIndicator: '$DEMOROOT$/spread/source/images/decreaseIndicator.png',
maxLevel: 2
});
sheet.showRowOutline(false);
sheet.outlineColumn.refresh();
}
function setOutlineColumnOptions(sheet) {
let options = sheet.outlineColumn.options();
}
</script>
<style scoped>
#app {
height: 100%;
}
.sample-tutorial {
position: relative;
height: 100%;
overflow: hidden;
}
.sample-spreadsheets {
width: calc(100% - 280px);
height: 100%;
overflow: hidden;
float: left;
}
.options-container {
float: right;
width: 280px;
padding: 12px;
height: 100%;
box-sizing: border-box;
background: #fbfbfb;
overflow: auto;
}
.options-row {
font-size: 14px;
padding: 5px;
margin-top: 10px;
}
input {
display: inline-block;
}
input[type="text"] {
width: 200px;
}
input[type="button"] {
padding: 4px 6px;
width: 100%;
margin-bottom: 10px;
}
label {
display: inline-block;
font-size: 13px;
}
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.desc {
padding: 2px 10px;
background-color: #F4F8EB;
}
</style>
<!DOCTYPE html>
<html style="height:100%;font-size:14px;">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>SpreadJS VUE</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css"
href="$DEMOROOT$/ko/vue3/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<script src="$DEMOROOT$/ko/vue3/node_modules/systemjs/dist/system.src.js"></script>
<script src="./systemjs.config.js"></script>
<script src="./compiler.js" type="module"></script>
<script src="$DEMOROOT$/spread/source/data/outlineColumn-wbs.js" type="text/javascript"></script>
<script>
var System = SystemJS;
System.import("./src/app.js");
System.import('$DEMOROOT$/ko/lib/vue3/license.js');
</script>
</head>
<body>
<div id="app"></div>
</body>
</html>
(function (global) {
SystemJS.config({
transpiler: 'plugin-babel',
babelOptions: {
es2015: true
},
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
packageConfigPaths: [
'./node_modules/*/package.json',
"./node_modules/@mescius/*/package.json",
"./node_modules/@babel/*/package.json",
"./node_modules/@vue/*/package.json"
],
map: {
'vue': "npm:vue/dist/vue.esm-browser.js",
'tiny-emitter': 'npm:tiny-emitter/index.js',
'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js',
"systemjs-babel-build": "npm:systemjs-plugin-babel/systemjs-babel-browser.js",
'@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js',
'@mescius/spread-sheets-resources-ko': 'npm:@mescius/spread-sheets-resources-ko/index.js',
'@mescius/spread-sheets-vue': 'npm:@mescius/spread-sheets-vue/index.js'
},
meta: {
'*.css': { loader: 'systemjs-plugin-css' },
'*.vue': { loader: "../plugin-vue/index.js" }
}
});
})(this);