본문으로 건너뛰기Skip to content
예제 첫화면Examples home

행 번호 모양과 체크박스 숨기기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.

활용Intermediate
직접 써 보기Live preview행 번호 모양과 체크박스 숨기기Row number options and hidden checkboxes

코드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)

빌드 도구(Vite 등)를 쓰는 프로젝트용 모듈 파일이에요. 설치 없이 바로 돌려 보려면 HTML 탭이나 직접 해보기를 쓰세요.

버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.

index.html
<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>
main.js
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));
example.js
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 } }),
};

Module files for a project with a bundler such as Vite. To run it with no setup, use the HTML tab or Try it.

When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.

index.html
<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>
main.js
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));
example.js
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 } }),
};