상태 목록에서 고르고 빈 메모 찾기Pick a status and find empty notes
정해진 값 중에서 고르는 필터와 '비어 있음 / 값 있음' 필터를 함께 쓸 수 있어요. 두 조건은 둘 다 만족하는 행만 남겨요.Combine a pick-from-list filter with an empty or filled check. Both conditions must hold for a row to stay.
코드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">
<select aria-label="상태" id="status">
<option value="all" selected>전체</option>
<option value="running">진행</option>
<option value="done">완료</option>
<option value="hold">보류</option>
</select>
<select aria-label="메모" id="memo">
<option value="any" selected>상관없음</option>
<option value="empty">비어 있음</option>
<option value="filled">값 있음</option>
</select>
</div>
<div id="grid" style="height: 560px"></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('status').addEventListener('change', (event) => actions.status(api, event.target.value));
document.getElementById('memo').addEventListener('change', (event) => actions.memo(api, event.target.value));const tasks = [
'견적서 발송',
'계약서 검토',
'세금계산서 발행',
'샘플 배송',
'시연 일정 조율',
'교육 자료 정리',
'고객 불만 접수',
'재고 확인',
];
const statuses = ['진행', '완료', '보류'];
const memos = ['고객 회신 대기', null, '내일 오전 처리', null, '담당자 휴가', null];
export const options = {
columns: [
{ id: 'task', title: '업무', width: 170 },
{ id: 'status', title: '상태', width: 90 },
{
id: 'memo',
title: '메모',
width: 190,
formatValue: (value) => (value == null || value === '' ? '' : String(value)),
},
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
task: tasks[i % 8],
status: statuses[(i * 5) % 3],
memo: memos[i % 6] ?? null,
})),
rowKey: 'id',
};
// 상태는 정해진 값 중에서 고르고('in'), 메모는 비어 있는지만 본다('isEmpty' / 'isNotEmpty').
// 두 조건은 함께 걸려요(둘 다 만족하는 행만 남아요).
const pick = { status: 'all', memo: 'any' };
function apply(api) {
const items = [];
if (pick.status !== 'all')
items.push({ columnId: 'status', operator: 'in', value: [pick.status] });
if (pick.memo === 'empty')
items.push({ columnId: 'memo', operator: 'isEmpty' });
if (pick.memo === 'filled')
items.push({ columnId: 'memo', operator: 'isNotEmpty' });
api.setFilterModel(items.length ? { match: 'all', items } : null);
}
export function setup(api, log) {
pick.status = 'all';
pick.memo = 'any';
const off = api.on('filterChanged', () => log({
ko: `보이는 행 ${api.getVisibleRowCount()} / 전체 ${api.getRowCount()}`,
en: `Visible rows ${api.getVisibleRowCount()} / total ${api.getRowCount()}`,
}));
return () => off();
}
// 조작 칸의 값은 언어와 상관없는 키라서, 키를 표의 값으로 바꿔 써요.
const STATUS_BY_KEY = { running: '진행', done: '완료', hold: '보류' };
export const actions = {
status: (api, value) => {
pick.status = value && value !== 'all' ? (STATUS_BY_KEY[value] ?? 'all') : 'all';
apply(api);
},
memo: (api, value) => {
pick.memo = value ?? 'any';
apply(api);
},
};<!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">
<select aria-label="상태" id="status">
<option value="all" selected>전체</option>
<option value="running">진행</option>
<option value="done">완료</option>
<option value="hold">보류</option>
</select>
<select aria-label="메모" id="memo">
<option value="any" selected>상관없음</option>
<option value="empty">비어 있음</option>
<option value="filled">값 있음</option>
</select>
</div>
<div id="grid" style="height: 560px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const tasks = [
'견적서 발송',
'계약서 검토',
'세금계산서 발행',
'샘플 배송',
'시연 일정 조율',
'교육 자료 정리',
'고객 불만 접수',
'재고 확인',
];
const statuses = ['진행', '완료', '보류'];
const memos = ['고객 회신 대기', null, '내일 오전 처리', null, '담당자 휴가', null];
const options = {
columns: [
{ id: 'task', title: '업무', width: 170 },
{ id: 'status', title: '상태', width: 90 },
{
id: 'memo',
title: '메모',
width: 190,
formatValue: (value) => (value == null || value === '' ? '' : String(value)),
},
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
task: tasks[i % 8],
status: statuses[(i * 5) % 3],
memo: memos[i % 6] ?? null,
})),
rowKey: 'id',
};
// 상태는 정해진 값 중에서 고르고('in'), 메모는 비어 있는지만 본다('isEmpty' / 'isNotEmpty').
// 두 조건은 함께 걸려요(둘 다 만족하는 행만 남아요).
const pick = { status: 'all', memo: 'any' };
function apply(api) {
const items = [];
if (pick.status !== 'all')
items.push({ columnId: 'status', operator: 'in', value: [pick.status] });
if (pick.memo === 'empty')
items.push({ columnId: 'memo', operator: 'isEmpty' });
if (pick.memo === 'filled')
items.push({ columnId: 'memo', operator: 'isNotEmpty' });
api.setFilterModel(items.length ? { match: 'all', items } : null);
}
function setup(api, log) {
pick.status = 'all';
pick.memo = 'any';
const off = api.on('filterChanged', () => log({
ko: `보이는 행 ${api.getVisibleRowCount()} / 전체 ${api.getRowCount()}`,
en: `Visible rows ${api.getVisibleRowCount()} / total ${api.getRowCount()}`,
}));
return () => off();
}
// 조작 칸의 값은 언어와 상관없는 키라서, 키를 표의 값으로 바꿔 써요.
const STATUS_BY_KEY = { running: '진행', done: '완료', hold: '보류' };
const actions = {
status: (api, value) => {
pick.status = value && value !== 'all' ? (STATUS_BY_KEY[value] ?? 'all') : 'all';
apply(api);
},
memo: (api, value) => {
pick.memo = value ?? 'any';
apply(api);
},
};
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('status').addEventListener('change', (event) => actions.status(api, event.target.value));
document.getElementById('memo').addEventListener('change', (event) => actions.memo(api, event.target.value));
</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">
<select
aria-label="상태"
disabled={!api}
onChange={(event) => api && actions.status(api, event.target.value)}
>
<option value="all">전체</option>
<option value="running">진행</option>
<option value="done">완료</option>
<option value="hold">보류</option>
</select>
<select defaultValue="all"
aria-label="메모"
disabled={!api}
onChange={(event) => api && actions.memo(api, event.target.value)}
>
<option value="any">상관없음</option>
<option value="empty">비어 있음</option>
<option value="filled">값 있음</option>
</select>
</div>
<Grid style={{ height: 560 }} ref={gridRef} options={options} />
</>
);
}import type { FilterItem, GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
status: string;
memo: string | null;
}
const tasks = [
'견적서 발송',
'계약서 검토',
'세금계산서 발행',
'샘플 배송',
'시연 일정 조율',
'교육 자료 정리',
'고객 불만 접수',
'재고 확인',
];
const statuses = ['진행', '완료', '보류'];
const memos = ['고객 회신 대기', null, '내일 오전 처리', null, '담당자 휴가', null];
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: '업무', width: 170 },
{ id: 'status', title: '상태', width: 90 },
{
id: 'memo',
title: '메모',
width: 190,
formatValue: (value) => (value == null || value === '' ? '' : String(value)),
},
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
task: tasks[i % 8] as string,
status: statuses[(i * 5) % 3] as string,
memo: memos[i % 6] ?? null,
})),
rowKey: 'id',
};
// 상태는 정해진 값 중에서 고르고('in'), 메모는 비어 있는지만 본다('isEmpty' / 'isNotEmpty').
// 두 조건은 함께 걸려요(둘 다 만족하는 행만 남아요).
const pick = { status: 'all', memo: 'any' };
function apply(api: GridApi<Row>): void {
const items: FilterItem[] = [];
if (pick.status !== 'all')
items.push({ columnId: 'status', operator: 'in', value: [pick.status] });
if (pick.memo === 'empty') items.push({ columnId: 'memo', operator: 'isEmpty' });
if (pick.memo === 'filled') items.push({ columnId: 'memo', operator: 'isNotEmpty' });
api.setFilterModel(items.length ? { match: 'all', items } : null);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
pick.status = 'all';
pick.memo = 'any';
const off = api.on('filterChanged', () =>
log({
ko: `보이는 행 ${api.getVisibleRowCount()} / 전체 ${api.getRowCount()}`,
en: `Visible rows ${api.getVisibleRowCount()} / total ${api.getRowCount()}`,
}),
);
return () => off();
}
// 조작 칸의 값은 언어와 상관없는 키라서, 키를 표의 값으로 바꿔 써요.
const STATUS_BY_KEY: Record<string, string> = { running: '진행', done: '완료', hold: '보류' };
export const actions = {
status: (api: GridApi<Row>, value?: string) => {
pick.status = value && value !== 'all' ? (STATUS_BY_KEY[value] ?? 'all') : 'all';
apply(api);
},
memo: (api: GridApi<Row>, value?: string) => {
pick.memo = value ?? 'any';
apply(api);
},
};버튼을 누르면 이 예제의 코드가 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">
<select
aria-label="상태"
:disabled="!api"
@change="api && actions.status(api, ($event.target as HTMLSelectElement).value)"
>
<option value="all" selected>전체</option>
<option value="running">진행</option>
<option value="done">완료</option>
<option value="hold">보류</option>
</select>
<select
aria-label="메모"
:disabled="!api"
@change="api && actions.memo(api, ($event.target as HTMLSelectElement).value)"
>
<option value="any" selected>상관없음</option>
<option value="empty">비어 있음</option>
<option value="filled">값 있음</option>
</select>
</div>
<Grid style="height: 560px" :options="options" @ready="onReady" />
</template>import type { FilterItem, GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
status: string;
memo: string | null;
}
const tasks = [
'견적서 발송',
'계약서 검토',
'세금계산서 발행',
'샘플 배송',
'시연 일정 조율',
'교육 자료 정리',
'고객 불만 접수',
'재고 확인',
];
const statuses = ['진행', '완료', '보류'];
const memos = ['고객 회신 대기', null, '내일 오전 처리', null, '담당자 휴가', null];
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: '업무', width: 170 },
{ id: 'status', title: '상태', width: 90 },
{
id: 'memo',
title: '메모',
width: 190,
formatValue: (value) => (value == null || value === '' ? '' : String(value)),
},
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
task: tasks[i % 8] as string,
status: statuses[(i * 5) % 3] as string,
memo: memos[i % 6] ?? null,
})),
rowKey: 'id',
};
// 상태는 정해진 값 중에서 고르고('in'), 메모는 비어 있는지만 본다('isEmpty' / 'isNotEmpty').
// 두 조건은 함께 걸려요(둘 다 만족하는 행만 남아요).
const pick = { status: 'all', memo: 'any' };
function apply(api: GridApi<Row>): void {
const items: FilterItem[] = [];
if (pick.status !== 'all')
items.push({ columnId: 'status', operator: 'in', value: [pick.status] });
if (pick.memo === 'empty') items.push({ columnId: 'memo', operator: 'isEmpty' });
if (pick.memo === 'filled') items.push({ columnId: 'memo', operator: 'isNotEmpty' });
api.setFilterModel(items.length ? { match: 'all', items } : null);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
pick.status = 'all';
pick.memo = 'any';
const off = api.on('filterChanged', () =>
log({
ko: `보이는 행 ${api.getVisibleRowCount()} / 전체 ${api.getRowCount()}`,
en: `Visible rows ${api.getVisibleRowCount()} / total ${api.getRowCount()}`,
}),
);
return () => off();
}
// 조작 칸의 값은 언어와 상관없는 키라서, 키를 표의 값으로 바꿔 써요.
const STATUS_BY_KEY: Record<string, string> = { running: '진행', done: '완료', hold: '보류' };
export const actions = {
status: (api: GridApi<Row>, value?: string) => {
pick.status = value && value !== 'all' ? (STATUS_BY_KEY[value] ?? 'all') : 'all';
apply(api);
},
memo: (api: GridApi<Row>, value?: string) => {
pick.memo = value ?? 'any';
apply(api);
},
};버튼을 누르면 이 예제의 코드가 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">
<select
aria-label="상태"
[disabled]="!api"
(change)="api && actions.status(api, $any($event.target).value)"
>
<option value="all" selected>전체</option>
<option value="running">진행</option>
<option value="done">완료</option>
<option value="hold">보류</option>
</select>
<select
aria-label="메모"
[disabled]="!api"
(change)="api && actions.memo(api, $any($event.target).value)"
>
<option value="any" selected>상관없음</option>
<option value="empty">비어 있음</option>
<option value="filled">값 있음</option>
</select>
</div>
<mx-grid style="height: 560px" [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 { FilterItem, GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
task: string;
status: string;
memo: string | null;
}
const tasks = [
'견적서 발송',
'계약서 검토',
'세금계산서 발행',
'샘플 배송',
'시연 일정 조율',
'교육 자료 정리',
'고객 불만 접수',
'재고 확인',
];
const statuses = ['진행', '완료', '보류'];
const memos = ['고객 회신 대기', null, '내일 오전 처리', null, '담당자 휴가', null];
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: '업무', width: 170 },
{ id: 'status', title: '상태', width: 90 },
{
id: 'memo',
title: '메모',
width: 190,
formatValue: (value) => (value == null || value === '' ? '' : String(value)),
},
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
task: tasks[i % 8] as string,
status: statuses[(i * 5) % 3] as string,
memo: memos[i % 6] ?? null,
})),
rowKey: 'id',
};
// 상태는 정해진 값 중에서 고르고('in'), 메모는 비어 있는지만 본다('isEmpty' / 'isNotEmpty').
// 두 조건은 함께 걸려요(둘 다 만족하는 행만 남아요).
const pick = { status: 'all', memo: 'any' };
function apply(api: GridApi<Row>): void {
const items: FilterItem[] = [];
if (pick.status !== 'all')
items.push({ columnId: 'status', operator: 'in', value: [pick.status] });
if (pick.memo === 'empty') items.push({ columnId: 'memo', operator: 'isEmpty' });
if (pick.memo === 'filled') items.push({ columnId: 'memo', operator: 'isNotEmpty' });
api.setFilterModel(items.length ? { match: 'all', items } : null);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
pick.status = 'all';
pick.memo = 'any';
const off = api.on('filterChanged', () =>
log({
ko: `보이는 행 ${api.getVisibleRowCount()} / 전체 ${api.getRowCount()}`,
en: `Visible rows ${api.getVisibleRowCount()} / total ${api.getRowCount()}`,
}),
);
return () => off();
}
// 조작 칸의 값은 언어와 상관없는 키라서, 키를 표의 값으로 바꿔 써요.
const STATUS_BY_KEY: Record<string, string> = { running: '진행', done: '완료', hold: '보류' };
export const actions = {
status: (api: GridApi<Row>, value?: string) => {
pick.status = value && value !== 'all' ? (STATUS_BY_KEY[value] ?? 'all') : 'all';
apply(api);
},
memo: (api: GridApi<Row>, value?: string) => {
pick.memo = value ?? 'any';
apply(api);
},
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div class="toolbar">
<select aria-label="Status" id="status">
<option value="all" selected>All</option>
<option value="running">In progress</option>
<option value="done">Done</option>
<option value="hold">On hold</option>
</select>
<select aria-label="Note" id="memo">
<option value="any" selected>Any</option>
<option value="empty">Empty</option>
<option value="filled">Filled</option>
</select>
</div>
<div id="grid" style="height: 560px"></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('status').addEventListener('change', (event) => actions.status(api, event.target.value));
document.getElementById('memo').addEventListener('change', (event) => actions.memo(api, event.target.value));const tasks = [
'Send quote',
'Review contract',
'Issue invoice',
'Ship sample',
'Schedule demo',
'Organize training material',
'Log customer complaint',
'Check inventory',
];
const statuses = ['In progress', 'Done', 'On hold'];
const memos = [
'Waiting for customer reply',
null,
'Handle tomorrow morning',
null,
'Owner on vacation',
null,
];
export const options = {
columns: [
{ id: 'task', title: 'Task', width: 200 },
{ id: 'status', title: 'Status', width: 110 },
{
id: 'memo',
title: 'Notes',
width: 210,
formatValue: (value) => (value == null || value === '' ? '' : String(value)),
},
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
task: tasks[i % 8],
status: statuses[(i * 5) % 3],
memo: memos[i % 6] ?? null,
})),
rowKey: 'id',
};
// Status is chosen from fixed values ('in'), and notes are only checked for being empty ('isEmpty' / 'isNotEmpty').
// Both conditions apply together (only rows that satisfy both stay).
const pick = { status: 'all', memo: 'any' };
function apply(api) {
const items = [];
if (pick.status !== 'all')
items.push({ columnId: 'status', operator: 'in', value: [pick.status] });
if (pick.memo === 'empty')
items.push({ columnId: 'memo', operator: 'isEmpty' });
if (pick.memo === 'filled')
items.push({ columnId: 'memo', operator: 'isNotEmpty' });
api.setFilterModel(items.length ? { match: 'all', items } : null);
}
export function setup(api, log) {
pick.status = 'all';
pick.memo = 'any';
const off = api.on('filterChanged', () => log(`Visible rows ${api.getVisibleRowCount()} / total ${api.getRowCount()}`));
return () => off();
}
// The control values are language-neutral keys; map them to the values in the table.
const STATUS_BY_KEY = {
running: 'In progress',
done: 'Done',
hold: 'On hold',
};
export const actions = {
status: (api, value) => {
pick.status = value && value !== 'all' ? (STATUS_BY_KEY[value] ?? 'all') : 'all';
apply(api);
},
memo: (api, value) => {
pick.memo = value ?? 'any';
apply(api);
},
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Pick a status and find empty notes</title>
</head>
<body>
<div class="toolbar">
<select aria-label="Status" id="status">
<option value="all" selected>All</option>
<option value="running">In progress</option>
<option value="done">Done</option>
<option value="hold">On hold</option>
</select>
<select aria-label="Note" id="memo">
<option value="any" selected>Any</option>
<option value="empty">Empty</option>
<option value="filled">Filled</option>
</select>
</div>
<div id="grid" style="height: 560px"></div>
<ul id="log" aria-live="polite"></ul>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const tasks = [
'Send quote',
'Review contract',
'Issue invoice',
'Ship sample',
'Schedule demo',
'Organize training material',
'Log customer complaint',
'Check inventory',
];
const statuses = ['In progress', 'Done', 'On hold'];
const memos = [
'Waiting for customer reply',
null,
'Handle tomorrow morning',
null,
'Owner on vacation',
null,
];
const options = {
columns: [
{ id: 'task', title: 'Task', width: 200 },
{ id: 'status', title: 'Status', width: 110 },
{
id: 'memo',
title: 'Notes',
width: 210,
formatValue: (value) => (value == null || value === '' ? '' : String(value)),
},
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
task: tasks[i % 8],
status: statuses[(i * 5) % 3],
memo: memos[i % 6] ?? null,
})),
rowKey: 'id',
};
// Status is chosen from fixed values ('in'), and notes are only checked for being empty ('isEmpty' / 'isNotEmpty').
// Both conditions apply together (only rows that satisfy both stay).
const pick = { status: 'all', memo: 'any' };
function apply(api) {
const items = [];
if (pick.status !== 'all')
items.push({ columnId: 'status', operator: 'in', value: [pick.status] });
if (pick.memo === 'empty')
items.push({ columnId: 'memo', operator: 'isEmpty' });
if (pick.memo === 'filled')
items.push({ columnId: 'memo', operator: 'isNotEmpty' });
api.setFilterModel(items.length ? { match: 'all', items } : null);
}
function setup(api, log) {
pick.status = 'all';
pick.memo = 'any';
const off = api.on('filterChanged', () => log(`Visible rows ${api.getVisibleRowCount()} / total ${api.getRowCount()}`));
return () => off();
}
// The control values are language-neutral keys; map them to the values in the table.
const STATUS_BY_KEY = {
running: 'In progress',
done: 'Done',
hold: 'On hold',
};
const actions = {
status: (api, value) => {
pick.status = value && value !== 'all' ? (STATUS_BY_KEY[value] ?? 'all') : 'all';
apply(api);
},
memo: (api, value) => {
pick.memo = value ?? 'any';
apply(api);
},
};
options.ariaLabel = "Pick a status and find empty notes";
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('status').addEventListener('change', (event) => actions.status(api, event.target.value));
document.getElementById('memo').addEventListener('change', (event) => actions.memo(api, event.target.value));
</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">
<select
aria-label="Status"
disabled={!api}
onChange={(event) => api && actions.status(api, event.target.value)}
>
<option value="all">All</option>
<option value="running">In progress</option>
<option value="done">Done</option>
<option value="hold">On hold</option>
</select>
<select defaultValue="all"
aria-label="Note"
disabled={!api}
onChange={(event) => api && actions.memo(api, event.target.value)}
>
<option value="any">Any</option>
<option value="empty">Empty</option>
<option value="filled">Filled</option>
</select>
</div>
<Grid style={{ height: 560 }} ref={gridRef} options={options} />
</>
);
}import type { FilterItem, GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string;
export interface Row {
id: number;
task: string;
status: string;
memo: string | null;
}
const tasks = [
'Send quote',
'Review contract',
'Issue invoice',
'Ship sample',
'Schedule demo',
'Organize training material',
'Log customer complaint',
'Check inventory',
];
const statuses = ['In progress', 'Done', 'On hold'];
const memos = [
'Waiting for customer reply',
null,
'Handle tomorrow morning',
null,
'Owner on vacation',
null,
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 200 },
{ id: 'status', title: 'Status', width: 110 },
{
id: 'memo',
title: 'Notes',
width: 210,
formatValue: (value) => (value == null || value === '' ? '' : String(value)),
},
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
task: tasks[i % 8] as string,
status: statuses[(i * 5) % 3] as string,
memo: memos[i % 6] ?? null,
})),
rowKey: 'id',
};
// Status is chosen from fixed values ('in'), and notes are only checked for being empty ('isEmpty' / 'isNotEmpty').
// Both conditions apply together (only rows that satisfy both stay).
const pick = { status: 'all', memo: 'any' };
function apply(api: GridApi<Row>): void {
const items: FilterItem[] = [];
if (pick.status !== 'all')
items.push({ columnId: 'status', operator: 'in', value: [pick.status] });
if (pick.memo === 'empty') items.push({ columnId: 'memo', operator: 'isEmpty' });
if (pick.memo === 'filled') items.push({ columnId: 'memo', operator: 'isNotEmpty' });
api.setFilterModel(items.length ? { match: 'all', items } : null);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
pick.status = 'all';
pick.memo = 'any';
const off = api.on('filterChanged', () =>
log(`Visible rows ${api.getVisibleRowCount()} / total ${api.getRowCount()}`),
);
return () => off();
}
// The control values are language-neutral keys; map them to the values in the table.
const STATUS_BY_KEY: Record<string, string> = {
running: 'In progress',
done: 'Done',
hold: 'On hold',
};
export const actions = {
status: (api: GridApi<Row>, value?: string) => {
pick.status = value && value !== 'all' ? (STATUS_BY_KEY[value] ?? 'all') : 'all';
apply(api);
},
memo: (api: GridApi<Row>, value?: string) => {
pick.memo = value ?? 'any';
apply(api);
},
};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">
<select
aria-label="Status"
:disabled="!api"
@change="api && actions.status(api, ($event.target as HTMLSelectElement).value)"
>
<option value="all" selected>All</option>
<option value="running">In progress</option>
<option value="done">Done</option>
<option value="hold">On hold</option>
</select>
<select
aria-label="Note"
:disabled="!api"
@change="api && actions.memo(api, ($event.target as HTMLSelectElement).value)"
>
<option value="any" selected>Any</option>
<option value="empty">Empty</option>
<option value="filled">Filled</option>
</select>
</div>
<Grid style="height: 560px" :options="options" @ready="onReady" />
</template>import type { FilterItem, GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string;
export interface Row {
id: number;
task: string;
status: string;
memo: string | null;
}
const tasks = [
'Send quote',
'Review contract',
'Issue invoice',
'Ship sample',
'Schedule demo',
'Organize training material',
'Log customer complaint',
'Check inventory',
];
const statuses = ['In progress', 'Done', 'On hold'];
const memos = [
'Waiting for customer reply',
null,
'Handle tomorrow morning',
null,
'Owner on vacation',
null,
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 200 },
{ id: 'status', title: 'Status', width: 110 },
{
id: 'memo',
title: 'Notes',
width: 210,
formatValue: (value) => (value == null || value === '' ? '' : String(value)),
},
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
task: tasks[i % 8] as string,
status: statuses[(i * 5) % 3] as string,
memo: memos[i % 6] ?? null,
})),
rowKey: 'id',
};
// Status is chosen from fixed values ('in'), and notes are only checked for being empty ('isEmpty' / 'isNotEmpty').
// Both conditions apply together (only rows that satisfy both stay).
const pick = { status: 'all', memo: 'any' };
function apply(api: GridApi<Row>): void {
const items: FilterItem[] = [];
if (pick.status !== 'all')
items.push({ columnId: 'status', operator: 'in', value: [pick.status] });
if (pick.memo === 'empty') items.push({ columnId: 'memo', operator: 'isEmpty' });
if (pick.memo === 'filled') items.push({ columnId: 'memo', operator: 'isNotEmpty' });
api.setFilterModel(items.length ? { match: 'all', items } : null);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
pick.status = 'all';
pick.memo = 'any';
const off = api.on('filterChanged', () =>
log(`Visible rows ${api.getVisibleRowCount()} / total ${api.getRowCount()}`),
);
return () => off();
}
// The control values are language-neutral keys; map them to the values in the table.
const STATUS_BY_KEY: Record<string, string> = {
running: 'In progress',
done: 'Done',
hold: 'On hold',
};
export const actions = {
status: (api: GridApi<Row>, value?: string) => {
pick.status = value && value !== 'all' ? (STATUS_BY_KEY[value] ?? 'all') : 'all';
apply(api);
},
memo: (api: GridApi<Row>, value?: string) => {
pick.memo = value ?? 'any';
apply(api);
},
};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">
<select
aria-label="Status"
[disabled]="!api"
(change)="api && actions.status(api, $any($event.target).value)"
>
<option value="all" selected>All</option>
<option value="running">In progress</option>
<option value="done">Done</option>
<option value="hold">On hold</option>
</select>
<select
aria-label="Note"
[disabled]="!api"
(change)="api && actions.memo(api, $any($event.target).value)"
>
<option value="any" selected>Any</option>
<option value="empty">Empty</option>
<option value="filled">Filled</option>
</select>
</div>
<mx-grid style="height: 560px" [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 { FilterItem, GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string;
export interface Row {
id: number;
task: string;
status: string;
memo: string | null;
}
const tasks = [
'Send quote',
'Review contract',
'Issue invoice',
'Ship sample',
'Schedule demo',
'Organize training material',
'Log customer complaint',
'Check inventory',
];
const statuses = ['In progress', 'Done', 'On hold'];
const memos = [
'Waiting for customer reply',
null,
'Handle tomorrow morning',
null,
'Owner on vacation',
null,
];
export const options: GridOptions<Row> = {
columns: [
{ id: 'task', title: 'Task', width: 200 },
{ id: 'status', title: 'Status', width: 110 },
{
id: 'memo',
title: 'Notes',
width: 210,
formatValue: (value) => (value == null || value === '' ? '' : String(value)),
},
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
task: tasks[i % 8] as string,
status: statuses[(i * 5) % 3] as string,
memo: memos[i % 6] ?? null,
})),
rowKey: 'id',
};
// Status is chosen from fixed values ('in'), and notes are only checked for being empty ('isEmpty' / 'isNotEmpty').
// Both conditions apply together (only rows that satisfy both stay).
const pick = { status: 'all', memo: 'any' };
function apply(api: GridApi<Row>): void {
const items: FilterItem[] = [];
if (pick.status !== 'all')
items.push({ columnId: 'status', operator: 'in', value: [pick.status] });
if (pick.memo === 'empty') items.push({ columnId: 'memo', operator: 'isEmpty' });
if (pick.memo === 'filled') items.push({ columnId: 'memo', operator: 'isNotEmpty' });
api.setFilterModel(items.length ? { match: 'all', items } : null);
}
export function setup(api: GridApi<Row>, log: (message: LogText) => void) {
pick.status = 'all';
pick.memo = 'any';
const off = api.on('filterChanged', () =>
log(`Visible rows ${api.getVisibleRowCount()} / total ${api.getRowCount()}`),
);
return () => off();
}
// The control values are language-neutral keys; map them to the values in the table.
const STATUS_BY_KEY: Record<string, string> = {
running: 'In progress',
done: 'Done',
hold: 'On hold',
};
export const actions = {
status: (api: GridApi<Row>, value?: string) => {
pick.status = value && value !== 'all' ? (STATUS_BY_KEY[value] ?? 'all') : 'all';
apply(api);
},
memo: (api: GridApi<Row>, value?: string) => {
pick.memo = value ?? 'any';
apply(api);
},
};