이벤트

SpreadJS는 워크시트에 있는 움직이는 개체에 대한 이벤트를 제공합니다. 아래 스프레드시트에 있는 움직이는 개체와의 상호 작용을 시도해 보고, 오른쪽 패널에 나타나는 JavaScript 이벤트를 확인하십시오.

움직이는 개체에는 다음 두 가지 종류의 이벤트가 있습니다. FloatingObjectSelectionChanged(움직이는 개체의 선택이 변경된 경우) 및 FloatingObjectChanged(움직이는 개체가 변경된 경우).
<template> <div class="sample-tutorial"> <gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread"> <gc-worksheet> </gc-worksheet> </gc-spread-sheets> <div class="options-container"> <textarea id="floatingObjectEvent" style="width: 95%; height: 90px" :value="text"></textarea> </div> </div> </template> <script setup> import GC from "@mescius/spread-sheets"; import '@mescius/spread-sheets-resources-ko'; GC.Spread.Common.CultureManager.culture("ko-kr"); import {ref} from 'vue'; const text = ref(''); function initSpread (spread) { let spreadNS = GC.Spread.Sheets; let sheet = spread.getSheet(0); sheet.suspendPaint(); let customFloatingObject = new spreadNS.FloatingObjects.FloatingObject("f1", 10, 10, 60, 64); customFloatingObject.startRow(1); customFloatingObject.startColumn(1); customFloatingObject.endColumn(3); customFloatingObject.endRow(4); let btn = document.createElement('button'); btn.style.width = "125px"; btn.style.height = "60px"; btn.style.background = "#82bc00"; btn.style.color = "white"; btn.style.textAlign = "center"; btn.style.border = "none"; btn.innerText = "Button"; customFloatingObject.content(btn); sheet.floatingObjects.add(customFloatingObject); sheet.resumePaint(); sheet.bind(spreadNS.Events.FloatingObjectSelectionChanged, function (e, args) { let _text = text.value; if (_text !== "") { _text += '\n'; } text.value = _text + "\n" + "Event:FloatingObjectSelectionChanged" + "\n" + "FloatingObject " + args.floatingObject.name() + "\n"; }); sheet.bind(spreadNS.Events.FloatingObjectChanged, function (e, args) { let _text = text.value; if (_text !== "") { _text += '\n'; } text.value = _text + "Event:FloatingObjectChanged" + "\n" + "FloatingObject " + args.floatingObject.name() + " " + args.propertyName + "\n"; }); } </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; } .option-row { font-size: 14px; padding: 5px; margin-top: 10px; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } </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> 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);