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

코드로 칸을 번쩍여 주의 끌기Draw attention by flashing cells from code

api.flashCells(cells, { duration, fade })는 값이 바뀌지 않아도 지정한 칸을 번쩍여요. 보이는 시간은 100~5000ms, 사라지는 시간은 0~2000ms예요.api.flashCells(cells, { duration, fade }) flashes the given cells even when no value changed. The visible time is 100-5000 ms and the fade 0-2000 ms.

입문Beginner
직접 써 보기Live preview코드로 칸을 번쩍여 주의 끌기Draw attention by flashing cells from code

코드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="one">한 칸</button>
    <button type="button" id="longRow">한 행 길게</button>
    <button type="button" id="column">한 열</button>
  </div>
  <div id="grid" style="height: 230px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('one').addEventListener('click', () => actions.one(api));
document.getElementById('longRow').addEventListener('click', () => actions.longRow(api));
document.getElementById('column').addEventListener('click', () => actions.column(api));
example.js
const rows = [
  { id: 1, task: '설계', owner: '민수', status: '진행' },
  { id: 2, task: '구현', owner: '서연', status: '대기' },
  { id: 3, task: '검수', owner: '지호', status: '대기' },
  { id: 4, task: '배포', owner: '하늘', status: '대기' },
];
// flashCells(cells, { duration, fade })는 값이 바뀌지 않아도 칸을 번쩍여요(주의를 끌 때). changeFlash가 꺼져 있어도 돼요.
export const options = {
  columns: [
    { id: 'id', title: '번호', kind: 'number', width: 70 },
    { id: 'task', title: '작업', width: 100 },
    { id: 'owner', title: '담당', width: 100 },
    { id: 'status', title: '상태', width: 100 },
  ],
  rows,
  rowKey: 'id',
};
export function setup(_api, log) {
  log({ ko: '버튼으로 칸을 번쩍여 보세요.', en: 'Use the buttons to flash cells.' });
  return () => undefined;
}
export const actions = {
  one: (api) => api.flashCells([{ rowKey: 2, columnId: 'status' }]),
  longRow: (api) => api.flashCells(['id', 'task', 'owner', 'status'].map((columnId) => ({ rowKey: 3, columnId })), { duration: 2500, fade: 800 }),
  column: (api) => api.flashCells(api.getRows().map((r) => ({ rowKey: r.id, columnId: 'owner' })), { duration: 400, fade: 0 }),
};

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="one">One cell</button>
    <button type="button" id="longRow">A row, long</button>
    <button type="button" id="column">A column</button>
  </div>
  <div id="grid" style="height: 230px"></div>
</div>
<script type="module" src="./main.js"></script>
main.js
import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('one').addEventListener('click', () => actions.one(api));
document.getElementById('longRow').addEventListener('click', () => actions.longRow(api));
document.getElementById('column').addEventListener('click', () => actions.column(api));
example.js
const rows = [
  { id: 1, task: 'Design', owner: 'Liam', status: 'Active' },
  { id: 2, task: 'Build', owner: 'Emma', status: 'Waiting' },
  { id: 3, task: 'Review', owner: 'Noah', status: 'Waiting' },
  { id: 4, task: 'Deploy', owner: 'Olivia', status: 'Waiting' },
];
// flashCells(cells, { duration, fade }) flashes cells even when the value does not change (to draw attention). It works even with changeFlash off.
export const options = {
  columns: [
    { id: 'id', title: 'No.', kind: 'number', width: 70 },
    { id: 'task', title: 'Task', width: 100 },
    { id: 'owner', title: 'Owner', width: 100 },
    { id: 'status', title: 'Status', width: 100 },
  ],
  rows,
  rowKey: 'id',
};
export function setup(_api, log) {
  log('Use the buttons to flash cells.');
  return () => undefined;
}
export const actions = {
  one: (api) => api.flashCells([{ rowKey: 2, columnId: 'status' }]),
  longRow: (api) => api.flashCells(['id', 'task', 'owner', 'status'].map((columnId) => ({ rowKey: 3, columnId })), { duration: 2500, fade: 800 }),
  column: (api) => api.flashCells(api.getRows().map((r) => ({ rowKey: r.id, columnId: 'owner' })), { duration: 400, fade: 0 }),
};