주문번호 여러 개 붙여넣어 한 번에 찾기Paste several order numbers to find them at once
엑셀이나 메신저에서 복사한 번호 여러 개를 쉼표·공백·줄바꿈 어느 것으로 구분했든 하나의 'in' 조건으로 바꿔 한 번에 찾아요. 정확히 같은 글자만 맞고, 없는 번호는 따로 알려 줘요.Paste a list of numbers separated by commas, spaces or new lines and it becomes one in condition. Only exact text matches, and numbers that do not exist are reported.
코드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">
<input
type="text"
aria-label="번호 목록"
placeholder="번호 목록 (예: SO-3002 SO-3005)"
id="orders"
/>
<button type="button" id="sample">예시 붙여넣기</button>
<button type="button" id="clear">지우기</button>
</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('orders').addEventListener('input', (event) => actions.orders(api, event.target.value));
document.getElementById('sample').addEventListener('click', () => actions.sample(api));
document.getElementById('clear').addEventListener('click', () => actions.clear(api));const customers = ['한빛물류', '푸른하늘식품', '북극성무역', '다온상사'];
export const options = {
columns: [
{ id: 'order', title: '주문번호', width: 130 },
{ id: 'customer', title: '고객사', width: 180 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
order: `SO-${3000 + i}`,
customer: customers[i % 4],
})),
rowKey: 'id',
};
let say = () => { };
let note = null;
export function setup(_api, log) {
say = log;
// 입력칸 바로 아래에 '못 찾은 번호'를 보여 줄 작은 줄을 만들어요(기록 창을 보지 않아도 알 수 있게).
note = document.createElement('div');
note.style.cssText =
'font-size: 12px; color: var(--muted); margin: -4px 0 8px; min-height: 16px;';
document.querySelector('.toolbar')?.insertAdjacentElement('afterend', note);
return () => {
note?.remove();
note = null;
};
}
// 쉼표, 공백, 줄바꿈, 세미콜론으로 구분된 번호 여러 개를 하나의 'in' 조건으로 바꿔요.
// 'in'은 글자가 정확히 같아야 맞고(대소문자도 구분), 같은 번호가 여러 번 들어 있어도 한 번만 세요.
function apply(api, text) {
const list = [...new Set(text.split(/[\s,;]+/).filter(Boolean))];
api.setFilterModel(list.length
? { match: 'all', items: [{ columnId: 'order', operator: 'in', value: list }] }
: null);
if (note)
note.textContent = '';
if (list.length === 0)
return say({ ko: `전체 ${api.getRowCount()}행`, en: `Total ${api.getRowCount()} rows` });
const known = new Set(api.getRows().map((row) => row.order));
const missing = list.filter((no) => !known.has(no));
if (note && missing.length)
note.textContent =
document.documentElement.dataset.lang === 'en'
? `${missing.length} numbers not found: ${missing.join(', ')}`
: `못 찾은 번호 ${missing.length}개: ${missing.join(', ')}`;
say({
ko: `${list.length}개 번호 중 ${list.length - missing.length}개를 찾았어요` +
(missing.length ? ` · 없는 번호: ${missing.join(', ')}` : ''),
en: `Found ${list.length - missing.length} of ${list.length} numbers` +
(missing.length ? ` · missing: ${missing.join(', ')}` : ''),
});
}
export const actions = {
orders: (api, value) => apply(api, value ?? ''),
sample: (api) => {
const text = 'SO-3002, SO-3005\nSO-3011 so-3007 SO-3999';
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement)
input.value = text.replace(/\n/g, ' ');
apply(api, text);
},
clear: (api) => {
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement)
input.value = '';
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">
<input
type="text"
aria-label="번호 목록"
placeholder="번호 목록 (예: SO-3002 SO-3005)"
id="orders"
/>
<button type="button" id="sample">예시 붙여넣기</button>
<button type="button" id="clear">지우기</button>
</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 customers = ['한빛물류', '푸른하늘식품', '북극성무역', '다온상사'];
const options = {
columns: [
{ id: 'order', title: '주문번호', width: 130 },
{ id: 'customer', title: '고객사', width: 180 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
order: `SO-${3000 + i}`,
customer: customers[i % 4],
})),
rowKey: 'id',
};
let say = () => { };
let note = null;
function setup(_api, log) {
say = log;
// 입력칸 바로 아래에 '못 찾은 번호'를 보여 줄 작은 줄을 만들어요(기록 창을 보지 않아도 알 수 있게).
note = document.createElement('div');
note.style.cssText =
'font-size: 12px; color: var(--muted); margin: -4px 0 8px; min-height: 16px;';
document.querySelector('.toolbar')?.insertAdjacentElement('afterend', note);
return () => {
note?.remove();
note = null;
};
}
// 쉼표, 공백, 줄바꿈, 세미콜론으로 구분된 번호 여러 개를 하나의 'in' 조건으로 바꿔요.
// 'in'은 글자가 정확히 같아야 맞고(대소문자도 구분), 같은 번호가 여러 번 들어 있어도 한 번만 세요.
function apply(api, text) {
const list = [...new Set(text.split(/[\s,;]+/).filter(Boolean))];
api.setFilterModel(list.length
? { match: 'all', items: [{ columnId: 'order', operator: 'in', value: list }] }
: null);
if (note)
note.textContent = '';
if (list.length === 0)
return say({ ko: `전체 ${api.getRowCount()}행`, en: `Total ${api.getRowCount()} rows` });
const known = new Set(api.getRows().map((row) => row.order));
const missing = list.filter((no) => !known.has(no));
if (note && missing.length)
note.textContent =
document.documentElement.dataset.lang === 'en'
? `${missing.length} numbers not found: ${missing.join(', ')}`
: `못 찾은 번호 ${missing.length}개: ${missing.join(', ')}`;
say({
ko: `${list.length}개 번호 중 ${list.length - missing.length}개를 찾았어요` +
(missing.length ? ` · 없는 번호: ${missing.join(', ')}` : ''),
en: `Found ${list.length - missing.length} of ${list.length} numbers` +
(missing.length ? ` · missing: ${missing.join(', ')}` : ''),
});
}
const actions = {
orders: (api, value) => apply(api, value ?? ''),
sample: (api) => {
const text = 'SO-3002, SO-3005\nSO-3011 so-3007 SO-3999';
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement)
input.value = text.replace(/\n/g, ' ');
apply(api, text);
},
clear: (api) => {
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement)
input.value = '';
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('orders').addEventListener('input', (event) => actions.orders(api, event.target.value));
document.getElementById('sample').addEventListener('click', () => actions.sample(api));
document.getElementById('clear').addEventListener('click', () => actions.clear(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">
<input
type="text"
aria-label="번호 목록"
placeholder="번호 목록 (예: SO-3002 SO-3005)"
disabled={!api}
onChange={(event) => api && actions.orders(api, event.target.value)}
/>
<button
type="button"
disabled={!api}
onClick={() => api && actions.sample(api)}
>예시 붙여넣기</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.clear(api)}
>지우기</button>
</div>
<Grid style={{ height: 560 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
order: string;
customer: string;
}
const customers = ['한빛물류', '푸른하늘식품', '북극성무역', '다온상사'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'order', title: '주문번호', width: 130 },
{ id: 'customer', title: '고객사', width: 180 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
order: `SO-${3000 + i}`,
customer: customers[i % 4] as string,
})),
rowKey: 'id',
};
let say: (message: LogText) => void = () => {};
let note: HTMLElement | null = null;
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
// 입력칸 바로 아래에 '못 찾은 번호'를 보여 줄 작은 줄을 만들어요(기록 창을 보지 않아도 알 수 있게).
note = document.createElement('div');
note.style.cssText =
'font-size: 12px; color: var(--muted); margin: -4px 0 8px; min-height: 16px;';
document.querySelector('.toolbar')?.insertAdjacentElement('afterend', note);
return () => {
note?.remove();
note = null;
};
}
// 쉼표, 공백, 줄바꿈, 세미콜론으로 구분된 번호 여러 개를 하나의 'in' 조건으로 바꿔요.
// 'in'은 글자가 정확히 같아야 맞고(대소문자도 구분), 같은 번호가 여러 번 들어 있어도 한 번만 세요.
function apply(api: GridApi<Row>, text: string): void {
const list = [...new Set(text.split(/[\s,;]+/).filter(Boolean))];
api.setFilterModel(
list.length
? { match: 'all', items: [{ columnId: 'order', operator: 'in', value: list }] }
: null,
);
if (note) note.textContent = '';
if (list.length === 0)
return say({ ko: `전체 ${api.getRowCount()}행`, en: `Total ${api.getRowCount()} rows` });
const known = new Set(api.getRows().map((row) => row.order));
const missing = list.filter((no) => !known.has(no));
if (note && missing.length)
note.textContent =
document.documentElement.dataset.lang === 'en'
? `${missing.length} numbers not found: ${missing.join(', ')}`
: `못 찾은 번호 ${missing.length}개: ${missing.join(', ')}`;
say({
ko:
`${list.length}개 번호 중 ${list.length - missing.length}개를 찾았어요` +
(missing.length ? ` · 없는 번호: ${missing.join(', ')}` : ''),
en:
`Found ${list.length - missing.length} of ${list.length} numbers` +
(missing.length ? ` · missing: ${missing.join(', ')}` : ''),
});
}
export const actions = {
orders: (api: GridApi<Row>, value?: string) => apply(api, value ?? ''),
sample: (api: GridApi<Row>) => {
const text = 'SO-3002, SO-3005\nSO-3011 so-3007 SO-3999';
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement) input.value = text.replace(/\n/g, ' ');
apply(api, text);
},
clear: (api: GridApi<Row>) => {
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement) input.value = '';
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">
<input
type="text"
aria-label="번호 목록"
placeholder="번호 목록 (예: SO-3002 SO-3005)"
:disabled="!api"
@input="api && actions.orders(api, ($event.target as HTMLInputElement).value)"
/>
<button type="button" :disabled="!api" @click="api && actions.sample(api)">예시 붙여넣기</button>
<button type="button" :disabled="!api" @click="api && actions.clear(api)">지우기</button>
</div>
<Grid style="height: 560px" :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;
order: string;
customer: string;
}
const customers = ['한빛물류', '푸른하늘식품', '북극성무역', '다온상사'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'order', title: '주문번호', width: 130 },
{ id: 'customer', title: '고객사', width: 180 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
order: `SO-${3000 + i}`,
customer: customers[i % 4] as string,
})),
rowKey: 'id',
};
let say: (message: LogText) => void = () => {};
let note: HTMLElement | null = null;
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
// 입력칸 바로 아래에 '못 찾은 번호'를 보여 줄 작은 줄을 만들어요(기록 창을 보지 않아도 알 수 있게).
note = document.createElement('div');
note.style.cssText =
'font-size: 12px; color: var(--muted); margin: -4px 0 8px; min-height: 16px;';
document.querySelector('.toolbar')?.insertAdjacentElement('afterend', note);
return () => {
note?.remove();
note = null;
};
}
// 쉼표, 공백, 줄바꿈, 세미콜론으로 구분된 번호 여러 개를 하나의 'in' 조건으로 바꿔요.
// 'in'은 글자가 정확히 같아야 맞고(대소문자도 구분), 같은 번호가 여러 번 들어 있어도 한 번만 세요.
function apply(api: GridApi<Row>, text: string): void {
const list = [...new Set(text.split(/[\s,;]+/).filter(Boolean))];
api.setFilterModel(
list.length
? { match: 'all', items: [{ columnId: 'order', operator: 'in', value: list }] }
: null,
);
if (note) note.textContent = '';
if (list.length === 0)
return say({ ko: `전체 ${api.getRowCount()}행`, en: `Total ${api.getRowCount()} rows` });
const known = new Set(api.getRows().map((row) => row.order));
const missing = list.filter((no) => !known.has(no));
if (note && missing.length)
note.textContent =
document.documentElement.dataset.lang === 'en'
? `${missing.length} numbers not found: ${missing.join(', ')}`
: `못 찾은 번호 ${missing.length}개: ${missing.join(', ')}`;
say({
ko:
`${list.length}개 번호 중 ${list.length - missing.length}개를 찾았어요` +
(missing.length ? ` · 없는 번호: ${missing.join(', ')}` : ''),
en:
`Found ${list.length - missing.length} of ${list.length} numbers` +
(missing.length ? ` · missing: ${missing.join(', ')}` : ''),
});
}
export const actions = {
orders: (api: GridApi<Row>, value?: string) => apply(api, value ?? ''),
sample: (api: GridApi<Row>) => {
const text = 'SO-3002, SO-3005\nSO-3011 so-3007 SO-3999';
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement) input.value = text.replace(/\n/g, ' ');
apply(api, text);
},
clear: (api: GridApi<Row>) => {
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement) input.value = '';
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">
<input
type="text"
aria-label="번호 목록"
placeholder="번호 목록 (예: SO-3002 SO-3005)"
[disabled]="!api"
(input)="api && actions.orders(api, $any($event.target).value)"
/>
<button
type="button"
[disabled]="!api"
(click)="api && actions.sample(api)"
>예시 붙여넣기</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.clear(api)"
>지우기</button>
</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 { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string | { ko: string; en: string };
export interface Row {
id: number;
order: string;
customer: string;
}
const customers = ['한빛물류', '푸른하늘식품', '북극성무역', '다온상사'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'order', title: '주문번호', width: 130 },
{ id: 'customer', title: '고객사', width: 180 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
order: `SO-${3000 + i}`,
customer: customers[i % 4] as string,
})),
rowKey: 'id',
};
let say: (message: LogText) => void = () => {};
let note: HTMLElement | null = null;
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
// 입력칸 바로 아래에 '못 찾은 번호'를 보여 줄 작은 줄을 만들어요(기록 창을 보지 않아도 알 수 있게).
note = document.createElement('div');
note.style.cssText =
'font-size: 12px; color: var(--muted); margin: -4px 0 8px; min-height: 16px;';
document.querySelector('.toolbar')?.insertAdjacentElement('afterend', note);
return () => {
note?.remove();
note = null;
};
}
// 쉼표, 공백, 줄바꿈, 세미콜론으로 구분된 번호 여러 개를 하나의 'in' 조건으로 바꿔요.
// 'in'은 글자가 정확히 같아야 맞고(대소문자도 구분), 같은 번호가 여러 번 들어 있어도 한 번만 세요.
function apply(api: GridApi<Row>, text: string): void {
const list = [...new Set(text.split(/[\s,;]+/).filter(Boolean))];
api.setFilterModel(
list.length
? { match: 'all', items: [{ columnId: 'order', operator: 'in', value: list }] }
: null,
);
if (note) note.textContent = '';
if (list.length === 0)
return say({ ko: `전체 ${api.getRowCount()}행`, en: `Total ${api.getRowCount()} rows` });
const known = new Set(api.getRows().map((row) => row.order));
const missing = list.filter((no) => !known.has(no));
if (note && missing.length)
note.textContent =
document.documentElement.dataset.lang === 'en'
? `${missing.length} numbers not found: ${missing.join(', ')}`
: `못 찾은 번호 ${missing.length}개: ${missing.join(', ')}`;
say({
ko:
`${list.length}개 번호 중 ${list.length - missing.length}개를 찾았어요` +
(missing.length ? ` · 없는 번호: ${missing.join(', ')}` : ''),
en:
`Found ${list.length - missing.length} of ${list.length} numbers` +
(missing.length ? ` · missing: ${missing.join(', ')}` : ''),
});
}
export const actions = {
orders: (api: GridApi<Row>, value?: string) => apply(api, value ?? ''),
sample: (api: GridApi<Row>) => {
const text = 'SO-3002, SO-3005\nSO-3011 so-3007 SO-3999';
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement) input.value = text.replace(/\n/g, ' ');
apply(api, text);
},
clear: (api: GridApi<Row>) => {
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement) input.value = '';
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">
<input
type="text"
aria-label="Order list"
placeholder="Order list (e.g. SO-3002 SO-3005)"
id="orders"
/>
<button type="button" id="sample">Paste sample</button>
<button type="button" id="clear">Clear</button>
</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('orders').addEventListener('input', (event) => actions.orders(api, event.target.value));
document.getElementById('sample').addEventListener('click', () => actions.sample(api));
document.getElementById('clear').addEventListener('click', () => actions.clear(api));const customers = ['Harbor Logistics', 'Bluesky Foods', 'Polaris Trading', 'Evergreen Supply'];
export const options = {
columns: [
{ id: 'order', title: 'Order No.', width: 130 },
{ id: 'customer', title: 'Customer', width: 180 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
order: `SO-${3000 + i}`,
customer: customers[i % 4],
})),
rowKey: 'id',
};
let say = () => { };
let note = null;
export function setup(_api, log) {
say = log;
// Create a small line right under the input to show the numbers not found (so you can see them without watching the log).
note = document.createElement('div');
note.style.cssText =
'font-size: 12px; color: var(--muted); margin: -4px 0 8px; min-height: 16px;';
document.querySelector('.toolbar')?.insertAdjacentElement('afterend', note);
return () => {
note?.remove();
note = null;
};
}
// Turns several numbers separated by commas, spaces, line breaks or semicolons into one 'in' condition.
// 'in' matches only exactly equal text (case matters), and a number that appears several times counts once.
function apply(api, text) {
const list = [...new Set(text.split(/[\s,;]+/).filter(Boolean))];
api.setFilterModel(list.length
? { match: 'all', items: [{ columnId: 'order', operator: 'in', value: list }] }
: null);
if (note)
note.textContent = '';
if (list.length === 0)
return say(`Total ${api.getRowCount()} rows`);
const known = new Set(api.getRows().map((row) => row.order));
const missing = list.filter((no) => !known.has(no));
if (note && missing.length)
note.textContent = `${missing.length} numbers not found: ${missing.join(', ')}`;
say(`Found ${list.length - missing.length} of ${list.length} numbers` +
(missing.length ? ` · missing: ${missing.join(', ')}` : ''));
}
export const actions = {
orders: (api, value) => apply(api, value ?? ''),
sample: (api) => {
const text = 'SO-3002, SO-3005\nSO-3011 so-3007 SO-3999';
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement)
input.value = text.replace(/\n/g, ' ');
apply(api, text);
},
clear: (api) => {
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement)
input.value = '';
apply(api, '');
},
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Paste several order numbers to find them at once</title>
</head>
<body>
<div class="toolbar">
<input
type="text"
aria-label="Order list"
placeholder="Order list (e.g. SO-3002 SO-3005)"
id="orders"
/>
<button type="button" id="sample">Paste sample</button>
<button type="button" id="clear">Clear</button>
</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 customers = ['Harbor Logistics', 'Bluesky Foods', 'Polaris Trading', 'Evergreen Supply'];
const options = {
columns: [
{ id: 'order', title: 'Order No.', width: 130 },
{ id: 'customer', title: 'Customer', width: 180 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
order: `SO-${3000 + i}`,
customer: customers[i % 4],
})),
rowKey: 'id',
};
let say = () => { };
let note = null;
function setup(_api, log) {
say = log;
// Create a small line right under the input to show the numbers not found (so you can see them without watching the log).
note = document.createElement('div');
note.style.cssText =
'font-size: 12px; color: var(--muted); margin: -4px 0 8px; min-height: 16px;';
document.querySelector('.toolbar')?.insertAdjacentElement('afterend', note);
return () => {
note?.remove();
note = null;
};
}
// Turns several numbers separated by commas, spaces, line breaks or semicolons into one 'in' condition.
// 'in' matches only exactly equal text (case matters), and a number that appears several times counts once.
function apply(api, text) {
const list = [...new Set(text.split(/[\s,;]+/).filter(Boolean))];
api.setFilterModel(list.length
? { match: 'all', items: [{ columnId: 'order', operator: 'in', value: list }] }
: null);
if (note)
note.textContent = '';
if (list.length === 0)
return say(`Total ${api.getRowCount()} rows`);
const known = new Set(api.getRows().map((row) => row.order));
const missing = list.filter((no) => !known.has(no));
if (note && missing.length)
note.textContent = `${missing.length} numbers not found: ${missing.join(', ')}`;
say(`Found ${list.length - missing.length} of ${list.length} numbers` +
(missing.length ? ` · missing: ${missing.join(', ')}` : ''));
}
const actions = {
orders: (api, value) => apply(api, value ?? ''),
sample: (api) => {
const text = 'SO-3002, SO-3005\nSO-3011 so-3007 SO-3999';
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement)
input.value = text.replace(/\n/g, ' ');
apply(api, text);
},
clear: (api) => {
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement)
input.value = '';
apply(api, '');
},
};
options.ariaLabel = "Paste several order numbers to find them at once";
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('orders').addEventListener('input', (event) => actions.orders(api, event.target.value));
document.getElementById('sample').addEventListener('click', () => actions.sample(api));
document.getElementById('clear').addEventListener('click', () => actions.clear(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">
<input
type="text"
aria-label="Order list"
placeholder="Order list (e.g. SO-3002 SO-3005)"
disabled={!api}
onChange={(event) => api && actions.orders(api, event.target.value)}
/>
<button
type="button"
disabled={!api}
onClick={() => api && actions.sample(api)}
>Paste sample</button>
<button
type="button"
disabled={!api}
onClick={() => api && actions.clear(api)}
>Clear</button>
</div>
<Grid style={{ height: 560 }} ref={gridRef} options={options} />
</>
);
}import type { GridApi, GridOptions } from '@maxgrid/react';
export type LogText = string;
export interface Row {
id: number;
order: string;
customer: string;
}
const customers = ['Harbor Logistics', 'Bluesky Foods', 'Polaris Trading', 'Evergreen Supply'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'order', title: 'Order No.', width: 130 },
{ id: 'customer', title: 'Customer', width: 180 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
order: `SO-${3000 + i}`,
customer: customers[i % 4] as string,
})),
rowKey: 'id',
};
let say: (message: LogText) => void = () => {};
let note: HTMLElement | null = null;
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
// Create a small line right under the input to show the numbers not found (so you can see them without watching the log).
note = document.createElement('div');
note.style.cssText =
'font-size: 12px; color: var(--muted); margin: -4px 0 8px; min-height: 16px;';
document.querySelector('.toolbar')?.insertAdjacentElement('afterend', note);
return () => {
note?.remove();
note = null;
};
}
// Turns several numbers separated by commas, spaces, line breaks or semicolons into one 'in' condition.
// 'in' matches only exactly equal text (case matters), and a number that appears several times counts once.
function apply(api: GridApi<Row>, text: string): void {
const list = [...new Set(text.split(/[\s,;]+/).filter(Boolean))];
api.setFilterModel(
list.length
? { match: 'all', items: [{ columnId: 'order', operator: 'in', value: list }] }
: null,
);
if (note) note.textContent = '';
if (list.length === 0) return say(`Total ${api.getRowCount()} rows`);
const known = new Set(api.getRows().map((row) => row.order));
const missing = list.filter((no) => !known.has(no));
if (note && missing.length)
note.textContent = `${missing.length} numbers not found: ${missing.join(', ')}`;
say(
`Found ${list.length - missing.length} of ${list.length} numbers` +
(missing.length ? ` · missing: ${missing.join(', ')}` : ''),
);
}
export const actions = {
orders: (api: GridApi<Row>, value?: string) => apply(api, value ?? ''),
sample: (api: GridApi<Row>) => {
const text = 'SO-3002, SO-3005\nSO-3011 so-3007 SO-3999';
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement) input.value = text.replace(/\n/g, ' ');
apply(api, text);
},
clear: (api: GridApi<Row>) => {
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement) input.value = '';
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">
<input
type="text"
aria-label="Order list"
placeholder="Order list (e.g. SO-3002 SO-3005)"
:disabled="!api"
@input="api && actions.orders(api, ($event.target as HTMLInputElement).value)"
/>
<button type="button" :disabled="!api" @click="api && actions.sample(api)">Paste sample</button>
<button type="button" :disabled="!api" @click="api && actions.clear(api)">Clear</button>
</div>
<Grid style="height: 560px" :options="options" @ready="onReady" />
</template>import type { GridApi, GridOptions } from '@maxgrid/vue';
export type LogText = string;
export interface Row {
id: number;
order: string;
customer: string;
}
const customers = ['Harbor Logistics', 'Bluesky Foods', 'Polaris Trading', 'Evergreen Supply'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'order', title: 'Order No.', width: 130 },
{ id: 'customer', title: 'Customer', width: 180 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
order: `SO-${3000 + i}`,
customer: customers[i % 4] as string,
})),
rowKey: 'id',
};
let say: (message: LogText) => void = () => {};
let note: HTMLElement | null = null;
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
// Create a small line right under the input to show the numbers not found (so you can see them without watching the log).
note = document.createElement('div');
note.style.cssText =
'font-size: 12px; color: var(--muted); margin: -4px 0 8px; min-height: 16px;';
document.querySelector('.toolbar')?.insertAdjacentElement('afterend', note);
return () => {
note?.remove();
note = null;
};
}
// Turns several numbers separated by commas, spaces, line breaks or semicolons into one 'in' condition.
// 'in' matches only exactly equal text (case matters), and a number that appears several times counts once.
function apply(api: GridApi<Row>, text: string): void {
const list = [...new Set(text.split(/[\s,;]+/).filter(Boolean))];
api.setFilterModel(
list.length
? { match: 'all', items: [{ columnId: 'order', operator: 'in', value: list }] }
: null,
);
if (note) note.textContent = '';
if (list.length === 0) return say(`Total ${api.getRowCount()} rows`);
const known = new Set(api.getRows().map((row) => row.order));
const missing = list.filter((no) => !known.has(no));
if (note && missing.length)
note.textContent = `${missing.length} numbers not found: ${missing.join(', ')}`;
say(
`Found ${list.length - missing.length} of ${list.length} numbers` +
(missing.length ? ` · missing: ${missing.join(', ')}` : ''),
);
}
export const actions = {
orders: (api: GridApi<Row>, value?: string) => apply(api, value ?? ''),
sample: (api: GridApi<Row>) => {
const text = 'SO-3002, SO-3005\nSO-3011 so-3007 SO-3999';
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement) input.value = text.replace(/\n/g, ' ');
apply(api, text);
},
clear: (api: GridApi<Row>) => {
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement) input.value = '';
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">
<input
type="text"
aria-label="Order list"
placeholder="Order list (e.g. SO-3002 SO-3005)"
[disabled]="!api"
(input)="api && actions.orders(api, $any($event.target).value)"
/>
<button
type="button"
[disabled]="!api"
(click)="api && actions.sample(api)"
>Paste sample</button>
<button
type="button"
[disabled]="!api"
(click)="api && actions.clear(api)"
>Clear</button>
</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 { GridApi, GridOptions } from '@maxgrid/angular';
export type LogText = string;
export interface Row {
id: number;
order: string;
customer: string;
}
const customers = ['Harbor Logistics', 'Bluesky Foods', 'Polaris Trading', 'Evergreen Supply'];
export const options: GridOptions<Row> = {
columns: [
{ id: 'order', title: 'Order No.', width: 130 },
{ id: 'customer', title: 'Customer', width: 180 },
],
rows: Array.from({ length: 16 }, (_, i) => ({
id: i + 1,
order: `SO-${3000 + i}`,
customer: customers[i % 4] as string,
})),
rowKey: 'id',
};
let say: (message: LogText) => void = () => {};
let note: HTMLElement | null = null;
export function setup(_api: GridApi<Row>, log: (message: LogText) => void) {
say = log;
// Create a small line right under the input to show the numbers not found (so you can see them without watching the log).
note = document.createElement('div');
note.style.cssText =
'font-size: 12px; color: var(--muted); margin: -4px 0 8px; min-height: 16px;';
document.querySelector('.toolbar')?.insertAdjacentElement('afterend', note);
return () => {
note?.remove();
note = null;
};
}
// Turns several numbers separated by commas, spaces, line breaks or semicolons into one 'in' condition.
// 'in' matches only exactly equal text (case matters), and a number that appears several times counts once.
function apply(api: GridApi<Row>, text: string): void {
const list = [...new Set(text.split(/[\s,;]+/).filter(Boolean))];
api.setFilterModel(
list.length
? { match: 'all', items: [{ columnId: 'order', operator: 'in', value: list }] }
: null,
);
if (note) note.textContent = '';
if (list.length === 0) return say(`Total ${api.getRowCount()} rows`);
const known = new Set(api.getRows().map((row) => row.order));
const missing = list.filter((no) => !known.has(no));
if (note && missing.length)
note.textContent = `${missing.length} numbers not found: ${missing.join(', ')}`;
say(
`Found ${list.length - missing.length} of ${list.length} numbers` +
(missing.length ? ` · missing: ${missing.join(', ')}` : ''),
);
}
export const actions = {
orders: (api: GridApi<Row>, value?: string) => apply(api, value ?? ''),
sample: (api: GridApi<Row>) => {
const text = 'SO-3002, SO-3005\nSO-3011 so-3007 SO-3999';
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement) input.value = text.replace(/\n/g, ' ');
apply(api, text);
},
clear: (api: GridApi<Row>) => {
const input = document.getElementById('orders');
if (input instanceof HTMLInputElement) input.value = '';
apply(api, '');
},
};