Spread 인스턴스에서 탐색하는 데 의존하는 비즈니스 논리가 있는 경우 유용할 수 있습니다.
moveToNextCell: 다음 셀로 이동합니다(Tab의 기본 동작).
moveToPreviousCell: 이전 셀로 이동합니다(Shift + Tab의 기본 동작).
selectNextControl: spread.nextControl 지정된 요소 또는 설정되지 않은 경우 자동 감지된 요소를 선택합니다.
selectPreviousControl: spread.previousControl 지정된 요소 또는 설정되지 않은 경우 자동 감지된 요소를 선택합니다.
moveToNextCellThenControl: 활성 셀이 표시 가능한 마지막 셀인 경우 다음 셀로 이동하고 다음 컨트롤을 선택합니다.
moveToPreviousCellThenControl: 활성 셀이 표시 가능한 첫 번째 셀인 경우 이전 셀로 이동하고 이전 컨트롤을 선택합니다.
nextControl 및 previousControl 메서드를 사용하여 선택한 컨트롤을 설정할 수 있습니다. 예:
Spread는 사용자 지정 명령을 생성할 수 있습니다. 예:
register 메서드를 사용하여 네비게이션 키 및 해당 작업을 설정합니다. 예:
register 인수의 순서는 다음과 같습니다:
name: 명령의 이름입니다.
execute: 명령의 실행 함수입니다.
key: 키의 유니코드입니다.
ctrl: 작업에 Ctrl 키를 사용하는 경우 true이고, 그렇지 않으면 false입니다.
shift: 작업에 Shift 키를 사용하는 경우 true이고, 그렇지 않으면 false입니다.
alt: 작업에 Alt 키를 사용하는 경우 true이고, 그렇지 않으면 false입니다.
meta: 작업에 Macintosh의 Command 키 또는 Microsoft Windows의 Windows 키를 사용하는 경우 true이고, 그렇지 않으면 false입니다.
hideSelection 옵션을 사용하여 Spread가 포커스를 잃을 때 선택 항목을 숨깁니다. 예:
import { Component, NgModule, enableProdMode } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import GC from '@mescius/spread-sheets';
import { SpreadSheetsModule } from '@mescius/spread-sheets-angular';
import '@mescius/spread-sheets-resources-ko';
GC.Spread.Common.CultureManager.culture("ko-kr");
import './styles.css';
@Component({
selector: 'app-component',
templateUrl: 'src/app.component.html'
})
export class AppComponent {
spread: GC.Spread.Sheets.Workbook;
hostStyle = {
width: 'calc(100% - 280px)',
height: '100%',
overflow: 'hidden',
float: 'left'
};
constructor() {
}
initSpread($event: any) {
let spread = $event.spread;
this.spread = spread;
let sheet = spread.getSheet(0);
sheet.setRowCount(20);
sheet.setColumnCount(10);
sheet.addSpan(0, 0, 1, 7);
sheet.setValue(0, 0, "press the \'Tab\' or \'Shift + Tab\' key, the selction will move in accordance.");
}
_alertHandle($event: any){
let value = $event.currentTarget.value;
alert(value);
}
_moveHandle(e: any){
let input = e.target;
let id = input.id, isShift = id.indexOf("shift") === 0,
value = parseInt(input.value, 10),
actions = GC.Spread.Sheets.Commands,
action;
switch (value) {
case 0:
action = isShift ? actions.moveToPreviousCell : actions.moveToNextCell;
break;
case 1:
action = isShift ? actions.selectPreviousControl : actions.selectNextControl;
break;
case 2:
action = isShift ? actions.moveToPreviousCellThenControl : actions.moveToNextCellThenControl;
break;
}
if (action) {
this.spread.commandManager().register("customCommand"+ new Date().valueOf(), action, GC.Spread.Commands.Key.tab, false, isShift, false, false);
}
}
_handle(e: any){
let input = e.target;
let id = input.id, isPre = id.indexOf("pre") === 0,
value = input.value,
control = value ? document.getElementById(value) : undefined;
if (isPre) {
this.spread.previousControl(control);
} else {
this.spread.nextControl(control);
}
}
hideSelection(e: any){
this.spread.options.hideSelection = e.target.checked;
}
}
@NgModule({
imports: [BrowserModule, SpreadSheetsModule],
declarations: [AppComponent],
exports: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {}
enableProdMode();
// Bootstrap application with hash style navigation and global services.
platformBrowserDynamic().bootstrapModule(AppModule);
<!doctype html>
<html style="height:100%;font-size:14px;">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="$DEMOROOT$/ko/angular/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<!-- Polyfills -->
<script src="$DEMOROOT$/ko/angular/node_modules/core-js/client/shim.min.js"></script>
<script src="$DEMOROOT$/ko/angular/node_modules/zone.js/fesm2015/zone.min.js"></script>
<!-- SystemJS -->
<script src="$DEMOROOT$/ko/angular/node_modules/systemjs/dist/system.js"></script>
<script src="systemjs.config.js"></script>
<script>
// workaround to load 'rxjs/operators' from the rxjs bundle
System.import('rxjs').then(function (m) {
System.import('@angular/compiler');
System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators));
System.import('$DEMOROOT$/ko/lib/angular/license.ts');
System.import('./src/app.component');
});
</script>
</head>
<body>
<app-component></app-component>
</body>
</html>
<div class="sample-tutorial">
<gc-spread-sheets [hostStyle]="hostStyle" (workbookInitialized)="initSpread($event)">
</gc-spread-sheets>
<div class="options-container">
<p>Change the “Tab for:” field to “Next Control” then click the Spread instance to give it focus.</p>
<p>Hit the Tab key and observe that the focus moves to the “Previous Edit” text box on this page.</p>
<p>You can utilize this functionality to change what specific navigation keys do in Spread.</p>
<div class="option-row" style="margin-bottom: 10px;">
<input type="text" id="preEdit" placeholder="Previous Edit" title="Candidate previous control" />
<input type="button" id="preButton" title="Candidate previous control too" value="Previous Button" (click)="_alertHandle($event)"/>
</div>
<div class="option-row">
<input type="text" id="nextEdit" placeholder="Next Edit" title="Candidate next control" />
<input type="button" id="nextButton" title="Candidate next control too" value="Next Button" (click)="_alertHandle($event)"/>
</div>
<div class="option-row">
<label>Tab for:</label>
<select id="tabAction" (change)="_moveHandle($event)">
<option value="0" selected="selected">Next cell</option>
<option value="1">Next control</option>
<option value="2">Next cell then control</option>
</select>
<label class="colorLabel">This controls which navigation action happens when the user presses Tab.</label>
</div>
<div class="option-row">
<label>Shift + Tab for:</label>
<select id="shiftTabAction" (change)="_moveHandle($event)">
<option value="0" selected="selected">Previous cell</option>
<option value="1">Previous control</option>
<option value="2">Previous cell then control</option>
</select>
<label class="colorLabel">This controls which navigation action happens when the user presses Shift+Tab.</label>
</div>
<div class="option-row">
<label>Next control:</label>
<select id="nextControl" (change)="_handle($event)">
<option value="" selected="selected">Not set (auto detect)</option>
<option value="nextEdit">Next Edit</option>
<option value="nextButton">Next Button</option>
</select>
<label class="colorLabel">This defines which control is the next control in relation to the Spread instance.</label>
</div>
<div class="option-row">
<label>Previous control:</label>
<select id="preControl" (change)="_handle($event)">
<option value="" selected="selected">Not set (auto detect)</option>
<option value="preEdit">Previous Edit</option>
<option value="preButton">Previous Button</option>
</select>
<label class="colorLabel">This defines which control is the previous control in relation to the Spread instance.</label>
</div>
<div class="option-row">
<input type="checkbox" id="hideSelection" (change)="hideSelection($event)"/>
<label for="hideSelection">Hide Selection</label>
<label class="colorLabel">Checking this box will hide the selection in the Spread instance.</label>
</div>
</div>
</div>
.sample-tutorial {
position: relative;
height: 100%;
overflow: hidden;
}
.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;
}
.options-toggle {
display: none;
}
input, select {
padding: 4px 6px;
margin: 4px 0;
width: 100%;
box-sizing: border-box;
}
input[type=checkbox] {
width: auto;
}
.colorLabel {
width: auto;
color: #606060;
display: block;
}
.demo-options {
margin-top: 5px;
}
p{
padding:2px 10px;
background-color:lavender;
}
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
(function (global) {
System.config({
transpiler: 'ts',
typescriptOptions: {
tsconfig: true
},
meta: {
'typescript': {
"exports": "ts"
},
'*.css': { loader: 'css' }
},
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
'core-js': 'npm:core-js/client/shim.min.js',
'zone': 'npm:zone.js/fesm2015/zone.min.js',
'rxjs': 'npm:rxjs/dist/bundles/rxjs.umd.min.js',
'@angular/core': 'npm:@angular/core/fesm2022',
'@angular/common': 'npm:@angular/common/fesm2022/common.mjs',
'@angular/compiler': 'npm:@angular/compiler/fesm2022/compiler.mjs',
'@angular/platform-browser': 'npm:@angular/platform-browser/fesm2022/platform-browser.mjs',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/fesm2022/platform-browser-dynamic.mjs',
'@angular/common/http': 'npm:@angular/common/fesm2022/http.mjs',
'@angular/router': 'npm:@angular/router/fesm2022/router.mjs',
'@angular/forms': 'npm:@angular/forms/fesm2022/forms.mjs',
'jszip': 'npm:jszip/dist/jszip.min.js',
'typescript': 'npm:typescript/lib/typescript.js',
'ts': './plugin.js',
'tslib':'npm:tslib/tslib.js',
'css': 'npm:systemjs-plugin-css/css.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-angular': 'npm:@mescius/spread-sheets-angular/fesm2020/mescius-spread-sheets-angular.mjs',
'@grapecity/jsob-test-dependency-package/react-components': 'npm:@grapecity/jsob-test-dependency-package/react-components/index.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
src: {
defaultExtension: 'ts'
},
rxjs: {
defaultExtension: 'js'
},
"node_modules": {
defaultExtension: 'js'
},
"node_modules/@angular": {
defaultExtension: 'mjs'
},
"@mescius/spread-sheets-angular": {
defaultExtension: 'mjs'
},
'@angular/core': {
defaultExtension: 'mjs',
main: 'core.mjs'
}
}
});
})(this);