행 번호 모양과 체크박스 숨기기Row number options and hidden checkboxes
rowNumbers로 머리글 글자·폭·첫 번호를 정하고 reverse로 아래에서부터 세요. isRowCheckVisible이 false를 돌려준 행은 체크박스를 그리지 않아요.rowNumbers sets the header text, width and first number, and reverse counts from the bottom. Rows for which isRowCheckVisible returns false draw no checkbox.
코드Code
탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.
이 화면은 새 모양 옵션을 켠 모양이에요: density: 'spacious', iconStyle: 'soft', motion: true (코드에 없으면 기본 모양으로 보여요)This preview has the new-look options on: density: 'spacious', iconStyle: 'soft', motion: true (without them in your code you get the default look)
버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<div id="app">
<div class="toolbar">
<button type="button" id="reverse">거꾸로</button>
<button type="button" id="forward">순서대로</button>
<button type="button" id="from100">100부터</button>
</div>
<div id="grid" style="height: 300px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options } from './example';
const api = createGrid(document.getElementById('grid'), options);
document.getElementById('reverse').addEventListener('click', () => actions.reverse(api));
document.getElementById('forward').addEventListener('click', () => actions.forward(api));
document.getElementById('from100').addEventListener('click', () => actions.from100(api));const rows = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `이름 ${i + 1}`,
score: (i * 7) % 30,
}));
// rowNumbers: 머리글 글자·폭·첫 번호를 정하고 reverse로 아래에서부터 세요. 점수가 같은 행의 체크박스는 isRowCheckVisible로 숨겨요.
export const options = {
columns: [
{ id: 'name', title: '이름', width: 140 },
{ id: 'score', title: '점수', kind: 'number', width: 100 },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
extraColumns: ['rowNumber', 'check'],
rowNumbers: { title: '순번', width: 64, start: 1, reverse: false },
isRowCheckVisible: (row) => row.score !== 0,
};
export const actions = {
reverse: (api) => api.setOptions({ rowNumbers: { title: '남은 수', width: 64, reverse: true } }),
forward: (api) => api.setOptions({ rowNumbers: { title: '순번', width: 64, start: 1 } }),
from100: (api) => api.setOptions({ rowNumbers: { title: '번호', width: 64, start: 100 } }),
};<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>행 번호 모양과 체크박스 숨기기</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="reverse">거꾸로</button>
<button type="button" id="forward">순서대로</button>
<button type="button" id="from100">100부터</button>
</div>
<div id="grid" style="height: 300px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const rows = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `이름 ${i + 1}`,
score: (i * 7) % 30,
}));
// rowNumbers: 머리글 글자·폭·첫 번호를 정하고 reverse로 아래에서부터 세요. 점수가 같은 행의 체크박스는 isRowCheckVisible로 숨겨요.
const options = {
columns: [
{ id: 'name', title: '이름', width: 140 },
{ id: 'score', title: '점수', kind: 'number', width: 100 },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
extraColumns: ['rowNumber', 'check'],
rowNumbers: { title: '순번', width: 64, start: 1, reverse: false },
isRowCheckVisible: (row) => row.score !== 0,
};
const actions = {
reverse: (api) => api.setOptions({ rowNumbers: { title: '남은 수', width: 64, reverse: true } }),
forward: (api) => api.setOptions({ rowNumbers: { title: '순번', width: 64, start: 1 } }),
from100: (api) => api.setOptions({ rowNumbers: { title: '번호', width: 64, start: 100 } }),
};
options.ariaLabel = "행 번호 모양과 체크박스 숨기기";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('reverse').addEventListener('click', () => actions.reverse(api));
document.getElementById('forward').addEventListener('click', () => actions.forward(api));
document.getElementById('from100').addEventListener('click', () => actions.from100(api));
</script>
</body>
</html>버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.reverse(api)}
>거꾸로</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.forward(api)}
>순서대로</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.from100(api)}
>100부터</button>
</div>
<Grid style={{ height: 300 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
name: string;
score: number;
}
const rows: Row[] = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `이름 ${i + 1}`,
score: (i * 7) % 30,
}));
// rowNumbers: 머리글 글자·폭·첫 번호를 정하고 reverse로 아래에서부터 세요. 점수가 같은 행의 체크박스는 isRowCheckVisible로 숨겨요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 140 },
{ id: 'score', title: '점수', kind: 'number', width: 100 },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
extraColumns: ['rowNumber', 'check'],
rowNumbers: { title: '순번', width: 64, start: 1, reverse: false },
isRowCheckVisible: (row) => row.score !== 0,
};
export const actions = {
reverse: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: '남은 수', width: 64, reverse: true } }),
forward: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: '순번', width: 64, start: 1 } }),
from100: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: '번호', width: 64, start: 100 } }),
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
}
</script>
<template>
<div class="toolbar">
<button type="button" :disabled="!api" @click="api && actions.reverse(api)">거꾸로</button>
<button type="button" :disabled="!api" @click="api && actions.forward(api)">순서대로</button>
<button type="button" :disabled="!api" @click="api && actions.from100(api)">100부터</button>
</div>
<Grid style="height: 300px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
name: string;
score: number;
}
const rows: Row[] = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `이름 ${i + 1}`,
score: (i * 7) % 30,
}));
// rowNumbers: 머리글 글자·폭·첫 번호를 정하고 reverse로 아래에서부터 세요. 점수가 같은 행의 체크박스는 isRowCheckVisible로 숨겨요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 140 },
{ id: 'score', title: '점수', kind: 'number', width: 100 },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
extraColumns: ['rowNumber', 'check'],
rowNumbers: { title: '순번', width: 64, start: 1, reverse: false },
isRowCheckVisible: (row) => row.score !== 0,
};
export const actions = {
reverse: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: '남은 수', width: 64, reverse: true } }),
forward: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: '순번', width: 64, start: 1 } }),
from100: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: '번호', width: 64, start: 100 } }),
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<button
type="button"
[disabled]="!api"
(click)="api && actions.reverse(api)"
>거꾸로</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.forward(api)"
>순서대로</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.from100(api)"
>100부터</button>
</div>
<mx-grid style="height: 300px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
}
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
name: string;
score: number;
}
const rows: Row[] = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `이름 ${i + 1}`,
score: (i * 7) % 30,
}));
// rowNumbers: 머리글 글자·폭·첫 번호를 정하고 reverse로 아래에서부터 세요. 점수가 같은 행의 체크박스는 isRowCheckVisible로 숨겨요.
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: '이름', width: 140 },
{ id: 'score', title: '점수', kind: 'number', width: 100 },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
extraColumns: ['rowNumber', 'check'],
rowNumbers: { title: '순번', width: 64, start: 1, reverse: false },
isRowCheckVisible: (row) => row.score !== 0,
};
export const actions = {
reverse: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: '남은 수', width: 64, reverse: true } }),
forward: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: '순번', width: 64, start: 1 } }),
from100: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: '번호', width: 64, start: 100 } }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div class="toolbar">
<button type="button" id="reverse">Reverse</button>
<button type="button" id="forward">Forward</button>
<button type="button" id="from100">From 100</button>
</div>
<div id="grid" style="height: 300px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { actions, options } from './example';
const api = createGrid(document.getElementById('grid'), options);
document.getElementById('reverse').addEventListener('click', () => actions.reverse(api));
document.getElementById('forward').addEventListener('click', () => actions.forward(api));
document.getElementById('from100').addEventListener('click', () => actions.from100(api));const rows = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `Name ${i + 1}`,
score: (i * 7) % 30,
}));
// rowNumbers: sets the header text, width and first number; reverse counts from the bottom. isRowCheckVisible hides the checkbox of rows whose score is 0.
export const options = {
columns: [
{ id: 'name', title: 'Name', width: 140 },
{ id: 'score', title: 'Score', kind: 'number', width: 100 },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
extraColumns: ['rowNumber', 'check'],
rowNumbers: { title: 'No.', width: 64, start: 1, reverse: false },
isRowCheckVisible: (row) => row.score !== 0,
};
export const actions = {
reverse: (api) => api.setOptions({ rowNumbers: { title: 'Remaining', width: 64, reverse: true } }),
forward: (api) => api.setOptions({ rowNumbers: { title: 'No.', width: 64, start: 1 } }),
from100: (api) => api.setOptions({ rowNumbers: { title: 'No.', width: 64, start: 100 } }),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Row number options and hidden checkboxes</title>
</head>
<body>
<div class="toolbar">
<button type="button" id="reverse">Reverse</button>
<button type="button" id="forward">Forward</button>
<button type="button" id="from100">From 100</button>
</div>
<div id="grid" style="height: 300px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const rows = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `Name ${i + 1}`,
score: (i * 7) % 30,
}));
// rowNumbers: sets the header text, width and first number; reverse counts from the bottom. isRowCheckVisible hides the checkbox of rows whose score is 0.
const options = {
columns: [
{ id: 'name', title: 'Name', width: 140 },
{ id: 'score', title: 'Score', kind: 'number', width: 100 },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
extraColumns: ['rowNumber', 'check'],
rowNumbers: { title: 'No.', width: 64, start: 1, reverse: false },
isRowCheckVisible: (row) => row.score !== 0,
};
const actions = {
reverse: (api) => api.setOptions({ rowNumbers: { title: 'Remaining', width: 64, reverse: true } }),
forward: (api) => api.setOptions({ rowNumbers: { title: 'No.', width: 64, start: 1 } }),
from100: (api) => api.setOptions({ rowNumbers: { title: 'No.', width: 64, start: 100 } }),
};
options.ariaLabel = "Row number options and hidden checkboxes";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
document.getElementById('reverse').addEventListener('click', () => actions.reverse(api));
document.getElementById('forward').addEventListener('click', () => actions.forward(api));
document.getElementById('from100').addEventListener('click', () => actions.from100(api));
</script>
</body>
</html>When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.reverse(api)}
>Reverse</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.forward(api)}
>Forward</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.from100(api)}
>From 100</button>
</div>
<Grid style={{ height: 300 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
name: string;
score: number;
}
const rows: Row[] = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `Name ${i + 1}`,
score: (i * 7) % 30,
}));
// rowNumbers: sets the header text, width and first number; reverse counts from the bottom. isRowCheckVisible hides the checkbox of rows whose score is 0.
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 140 },
{ id: 'score', title: 'Score', kind: 'number', width: 100 },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
extraColumns: ['rowNumber', 'check'],
rowNumbers: { title: 'No.', width: 64, start: 1, reverse: false },
isRowCheckVisible: (row) => row.score !== 0,
};
export const actions = {
reverse: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: 'Remaining', width: 64, reverse: true } }),
forward: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: 'No.', width: 64, start: 1 } }),
from100: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: 'No.', width: 64, start: 100 } }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
}
</script>
<template>
<div class="toolbar">
<button type="button" :disabled="!api" @click="api && actions.reverse(api)">Reverse</button>
<button type="button" :disabled="!api" @click="api && actions.forward(api)">Forward</button>
<button type="button" :disabled="!api" @click="api && actions.from100(api)">From 100</button>
</div>
<Grid style="height: 300px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
name: string;
score: number;
}
const rows: Row[] = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `Name ${i + 1}`,
score: (i * 7) % 30,
}));
// rowNumbers: sets the header text, width and first number; reverse counts from the bottom. isRowCheckVisible hides the checkbox of rows whose score is 0.
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 140 },
{ id: 'score', title: 'Score', kind: 'number', width: 100 },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
extraColumns: ['rowNumber', 'check'],
rowNumbers: { title: 'No.', width: 64, start: 1, reverse: false },
isRowCheckVisible: (row) => row.score !== 0,
};
export const actions = {
reverse: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: 'Remaining', width: 64, reverse: true } }),
forward: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: 'No.', width: 64, start: 1 } }),
from100: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: 'No.', width: 64, start: 100 } }),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<div class="toolbar">
<button
type="button"
[disabled]="!api"
(click)="api && actions.reverse(api)"
>Reverse</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.forward(api)"
>Forward</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.from100(api)"
>From 100</button>
</div>
<mx-grid style="height: 300px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
}
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
name: string;
score: number;
}
const rows: Row[] = Array.from({ length: 12 }, (_, i) => ({
id: i + 1,
name: `Name ${i + 1}`,
score: (i * 7) % 30,
}));
// rowNumbers: sets the header text, width and first number; reverse counts from the bottom. isRowCheckVisible hides the checkbox of rows whose score is 0.
export const options: GridOptions<Row> = {
columns: [
{ id: 'name', title: 'Name', width: 140 },
{ id: 'score', title: 'Score', kind: 'number', width: 100 },
],
rows,
rowKey: 'id',
selection: { mode: 'multiple', checkbox: true },
extraColumns: ['rowNumber', 'check'],
rowNumbers: { title: 'No.', width: 64, start: 1, reverse: false },
isRowCheckVisible: (row) => row.score !== 0,
};
export const actions = {
reverse: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: 'Remaining', width: 64, reverse: true } }),
forward: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: 'No.', width: 64, start: 1 } }),
from100: (api: GridApi<Row>) =>
api.setOptions({ rowNumbers: { title: 'No.', width: 64, start: 100 } }),
};