행 작업
행 작업은 기본적으로 활성화되며, 테이블 시트의 행 헤더에 있습니다.
기본 제공되어 추가할 수 있는 행 작업이 있습니다.
이름
설명
pinRow
행 고정
dirtyStatus
행의 데이터 변경 사항 표시
warningInfo
행의 경고 정보 표시
removeRow
행 제거
saveRow
행의 데이터 변경 사항 저장
resetRow
행의 데이터 변경 사항 재설정
제거, 저장, 재설정 작업 추가:
새 행
새 행은 기본적으로 활성화되어 있으며, 테이블 시트 아래쪽에 있습니다. 다음을 사용하여 숨기거나 표시할 수 있습니다.
/*REPLACE_MARKER*/
/*DO NOT DELETE THESE COMMENTS*/
var sheet;
window.onload = function () {
var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 0 });
//register self-defined row action command
initSpread(spread);
bindEvents();
};
function initSpread(spread) {
spread.suspendPaint();
spread.clearSheets();
spread.options.autoFitType = GC.Spread.Sheets.AutoFitType.cellWithHeader;
//init a data manager
var dataManager = spread.dataManager();
var myTable = dataManager.addTable("myTable", {
data:employees
});
//init a table sheet
sheet = spread.addSheetTab(0, "MyTableSheet", GC.Spread.Sheets.SheetType.tableSheet);
var rowActions = GC.Spread.Sheets.TableSheet.BuiltInRowActions;
let options = sheet.rowActionOptions();
options.push(
rowActions.removeRow,
rowActions.saveRow,
rowActions.resetRow,
);
sheet.rowActionOptions(options);
//bind a view to the table sheet
myTable.fetch().then(function () {
var view = myTable.addView("myView", [
{ value: "Id", width: 50, caption: "ID" },
{ value: "FirstName", width: 100, caption: "First Name" },
{ value: "LastName", width: 100, caption: "Last Name" },
{ value: "HomePhone", width: 150, caption: "Phone" },
{ value: "PhotoPath", width: 150, caption: "Attachment" },
{ value: "Notes", width: 400, caption: "Comments" },
]);
sheet.setDataView(view);
});
spread.resumePaint();
}
function bindEvents() {
var changeOptionButton = document.getElementById('change-option');
changeOptionButton.addEventListener('click', function () {
let options = sheet.rowActionOptions();
if (options.length === 1) {
changeOptionButton.value = 'hide remove/save/reset'
var rowActions = GC.Spread.Sheets.TableSheet.BuiltInRowActions;
options.push(setTooltip(rowActions.removeRow, 'Remove'));
options.push(setTooltip(rowActions.saveRow, 'Save'));
options.push(setTooltip(rowActions.resetRow, 'Reset'));
} else {
changeOptionButton.value = 'show remove/save/reset'
options.splice(1, options.length);
}
sheet.rowActionOptions(options);
});
var showButton = document.getElementById('show-button');
showButton.addEventListener('change', function () {
sheet.options.allowAddNew = showButton.checked;
});
}
function setTooltip(options, tooltip) {
options.tooltip = tooltip;
return options;
}
function getProperty(domId, prop) {
return document.getElementById(domId)[prop];
}
function setProperty(domId, prop, value) {
document.getElementById(domId)[prop] = value;
}
<!doctype html>
<html style="height:100%;font-size:14px;">
<head>
<meta name="spreadjs culture" content="ko-kr" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="$DEMOROOT$/ko/purejs/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<!-- Promise Polyfill for IE, https://www.npmjs.com/package/promise-polyfill -->
<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"></script>
<script src="$DEMOROOT$/ko/purejs/node_modules/@mescius/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script>
<script src="$DEMOROOT$/ko/purejs/node_modules/@mescius/spread-sheets-tablesheet/dist/gc.spread.sheets.tablesheet.min.js" type="text/javascript"></script>
<script src="$DEMOROOT$/ko/purejs/node_modules/@mescius/spread-sheets-resources-ko/dist/gc.spread.sheets.resources.ko.min.js" type="text/javascript"></script>
<script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script>
<script src="$DEMOROOT$/spread/source/data/employees.js" type="text/javascript"></script>
<script src="app.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="sample-tutorial">
<div id="ss" class="sample-spreadsheets"></div>
<div id="options-container" class="options-container">
<fieldset>
<legend>Row Action</legend>
<div class="field-line">
<input type="button" id="change-option" value="hide remove/save/reset">
</div>
</fieldset>
<fieldset>
<legend>New Row</legend>
<div class="field-line">
<span>visible: </span><input type="checkbox" checked="checked" id="show-button" />
</div>
</fieldset>
</div>
</div>
</html>
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
fieldset {
padding: 6px;
margin: 0;
margin-top: 10px;
}
.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;
}
fieldset span,
fieldset input,
fieldset select {
display: inline-block;
text-align: left;
}
fieldset span {
width: 50px;
}
fieldset input[type=text] {
width: calc(100% - 58px);
}
fieldset input[type=button] {
width: 100%;
text-align: center;
}
fieldset select {
width: calc(100% - 50px);
}
.field-line {
margin-top: 4px;
}