코드로 칸을 번쩍여 주의 끌기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.
코드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="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>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));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 }),
};<!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="one">한 칸</button>
<button type="button" id="longRow">한 행 길게</button>
<button type="button" id="column">한 열</button>
</div>
<div id="grid" style="height: 230px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
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가 꺼져 있어도 돼요.
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',
};
function setup(_api, log) {
log({ ko: '버튼으로 칸을 번쩍여 보세요.', en: 'Use the buttons to flash cells.' });
return () => undefined;
}
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 }),
};
options.ariaLabel = "코드로 칸을 번쩍여 주의 끌기";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('one').addEventListener('click', () => actions.one(api));
document.getElementById('longRow').addEventListener('click', () => actions.longRow(api));
document.getElementById('column').addEventListener('click', () => actions.column(api));
</script>
</body>
</html>버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.one(api)}
>한 칸</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.longRow(api)}
>한 행 길게</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.column(api)}
>한 열</button>
</div>
<Grid style={{ height: 230 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
owner: string;
status: string;
}
const rows: Row[] = [
{ 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: GridOptions<Row> = {
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: GridApi<Row>, log: (message: LogText) => void) {
log({ ko: '버튼으로 칸을 번쩍여 보세요.', en: 'Use the buttons to flash cells.' });
return () => undefined;
}
export const actions = {
one: (api: GridApi<Row>) => api.flashCells([{ rowKey: 2, columnId: 'status' }]),
longRow: (api: GridApi<Row>) =>
api.flashCells(
['id', 'task', 'owner', 'status'].map((columnId) => ({ rowKey: 3, columnId })),
{ duration: 2500, fade: 800 },
),
column: (api: GridApi<Row>) =>
api.flashCells(
api.getRows().map((r) => ({ rowKey: r.id, columnId: 'owner' })),
{ duration: 400, fade: 0 },
),
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<button type="button" :disabled="!api" @click="api && actions.one(api)">한 칸</button>
<button type="button" :disabled="!api" @click="api && actions.longRow(api)">한 행 길게</button>
<button type="button" :disabled="!api" @click="api && actions.column(api)">한 열</button>
</div>
<Grid style="height: 230px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
owner: string;
status: string;
}
const rows: Row[] = [
{ 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: GridOptions<Row> = {
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: GridApi<Row>, log: (message: LogText) => void) {
log({ ko: '버튼으로 칸을 번쩍여 보세요.', en: 'Use the buttons to flash cells.' });
return () => undefined;
}
export const actions = {
one: (api: GridApi<Row>) => api.flashCells([{ rowKey: 2, columnId: 'status' }]),
longRow: (api: GridApi<Row>) =>
api.flashCells(
['id', 'task', 'owner', 'status'].map((columnId) => ({ rowKey: 3, columnId })),
{ duration: 2500, fade: 800 },
),
column: (api: GridApi<Row>) =>
api.flashCells(
api.getRows().map((r) => ({ rowKey: r.id, columnId: 'owner' })),
{ duration: 400, fade: 0 },
),
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, 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.one(api)"
>한 칸</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.longRow(api)"
>한 행 길게</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.column(api)"
>한 열</button>
</div>
<mx-grid style="height: 230px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
owner: string;
status: string;
}
const rows: Row[] = [
{ 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: GridOptions<Row> = {
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: GridApi<Row>, log: (message: LogText) => void) {
log({ ko: '버튼으로 칸을 번쩍여 보세요.', en: 'Use the buttons to flash cells.' });
return () => undefined;
}
export const actions = {
one: (api: GridApi<Row>) => api.flashCells([{ rowKey: 2, columnId: 'status' }]),
longRow: (api: GridApi<Row>) =>
api.flashCells(
['id', 'task', 'owner', 'status'].map((columnId) => ({ rowKey: 3, columnId })),
{ duration: 2500, fade: 800 },
),
column: (api: GridApi<Row>) =>
api.flashCells(
api.getRows().map((r) => ({ rowKey: r.id, columnId: 'owner' })),
{ duration: 400, fade: 0 },
),
};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="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>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));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 }),
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Draw attention by flashing cells from code</title>
</head>
<body>
<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>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
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.
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',
};
function setup(_api, log) {
log('Use the buttons to flash cells.');
return () => undefined;
}
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 }),
};
options.ariaLabel = "Draw attention by flashing cells from code";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
setup(api, (message) => {
const item = document.createElement('li');
item.textContent =
typeof message === 'string' ? message : navigator.language.startsWith('ko') ? message.ko : message.en;
document.getElementById('log').prepend(item);
});
document.getElementById('one').addEventListener('click', () => actions.one(api));
document.getElementById('longRow').addEventListener('click', () => actions.longRow(api));
document.getElementById('column').addEventListener('click', () => actions.column(api));
</script>
</body>
</html>When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { useEffect } from 'react';
import { Grid, useGridApi } from '@maxgrid/react';
import { actions, options, setup, type Row } from './example';
export function ExampleGrid() {
const [api, gridRef] = useGridApi<Row>();
useEffect(() => (api ? setup(api, console.log) : undefined), [api]);
return (
<>
<div className="toolbar">
<button
type="button"
disabled={!api}
onClick={() => api && actions.one(api)}
>One cell</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.longRow(api)}
>A row, long</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.column(api)}
>A column</button>
</div>
<Grid style={{ height: 230 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string;
export interface Row {
id: number;
task: string;
owner: string;
status: string;
}
const rows: Row[] = [
{ 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: GridOptions<Row> = {
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: GridApi<Row>, log: (message: string) => void) {
log('Use the buttons to flash cells.');
return () => undefined;
}
export const actions = {
one: (api: GridApi<Row>) => api.flashCells([{ rowKey: 2, columnId: 'status' }]),
longRow: (api: GridApi<Row>) =>
api.flashCells(
['id', 'task', 'owner', 'status'].map((columnId) => ({ rowKey: 3, columnId })),
{ duration: 2500, fade: 800 },
),
column: (api: GridApi<Row>) =>
api.flashCells(
api.getRows().map((r) => ({ rowKey: r.id, columnId: 'owner' })),
{ duration: 400, fade: 0 },
),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { onBeforeUnmount, shallowRef } from 'vue';
import { Grid, type GridApi } from '@maxgrid/vue';
import { actions, options, setup, type Row } from './example';
const api = shallowRef<GridApi<Row> | null>(null);
let stop: (() => void) | undefined;
function onReady(event: { api: GridApi<Row> }) {
api.value = event.api;
stop = setup(event.api, console.log);
}
onBeforeUnmount(() => stop?.());
</script>
<template>
<div class="toolbar">
<button type="button" :disabled="!api" @click="api && actions.one(api)">One cell</button>
<button type="button" :disabled="!api" @click="api && actions.longRow(api)">A row, long</button>
<button type="button" :disabled="!api" @click="api && actions.column(api)">A column</button>
</div>
<Grid style="height: 230px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string;
export interface Row {
id: number;
task: string;
owner: string;
status: string;
}
const rows: Row[] = [
{ 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: GridOptions<Row> = {
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: GridApi<Row>, log: (message: string) => void) {
log('Use the buttons to flash cells.');
return () => undefined;
}
export const actions = {
one: (api: GridApi<Row>) => api.flashCells([{ rowKey: 2, columnId: 'status' }]),
longRow: (api: GridApi<Row>) =>
api.flashCells(
['id', 'task', 'owner', 'status'].map((columnId) => ({ rowKey: 3, columnId })),
{ duration: 2500, fade: 800 },
),
column: (api: GridApi<Row>) =>
api.flashCells(
api.getRows().map((r) => ({ rowKey: r.id, columnId: 'owner' })),
{ duration: 400, fade: 0 },
),
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component, OnDestroy } from '@angular/core';
import { GridComponent, isGridEvent, type GridApi, type GridEventMessage } from '@maxgrid/angular';
import { actions, options, setup, 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.one(api)"
>One cell</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.longRow(api)"
>A row, long</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.column(api)"
>A column</button>
</div>
<mx-grid style="height: 230px" [options]="options" [events]="relayed" (gridEvent)="onEvent($event)" />
`,
})
export class ExampleGridComponent implements OnDestroy {
readonly options = options;
readonly actions = actions;
readonly relayed = ['ready'] as const;
api: GridApi<Row> | null = null;
private stop: (() => void) | null = null;
onEvent(event: GridEventMessage<Row>): void {
if (isGridEvent(event, 'ready')) {
this.api = event.payload.api;
this.stop = setup(this.api, console.log);
}
}
ngOnDestroy(): void {
this.stop?.();
}
}import type { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string;
export interface Row {
id: number;
task: string;
owner: string;
status: string;
}
const rows: Row[] = [
{ 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: GridOptions<Row> = {
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: GridApi<Row>, log: (message: string) => void) {
log('Use the buttons to flash cells.');
return () => undefined;
}
export const actions = {
one: (api: GridApi<Row>) => api.flashCells([{ rowKey: 2, columnId: 'status' }]),
longRow: (api: GridApi<Row>) =>
api.flashCells(
['id', 'task', 'owner', 'status'].map((columnId) => ({ rowKey: 3, columnId })),
{ duration: 2500, fade: 800 },
),
column: (api: GridApi<Row>) =>
api.flashCells(
api.getRows().map((r) => ({ rowKey: r.id, columnId: 'owner' })),
{ duration: 400, fade: 0 },
),
};