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

주문번호 여러 개 붙여넣어 한 번에 찾기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.

활용Intermediate
직접 써 보기Live preview주문번호 여러 개 붙여넣어 한 번에 찾기Paste several order numbers to find them at once

코드Code

탭을 골라 코드를 복사하세요. 위 화면은 이 코드를 그대로 실행한 결과예요.Pick a tab and copy the code. The preview above runs exactly this code.

이 화면은 새 모양 옵션을 켠 모양이에요: density: 'spacious', iconStyle: 'soft', motion: true (코드에 없으면 기본 모양으로 보여요)This preview has the new-look options on: density: 'spacious', iconStyle: 'soft', motion: true (without them in your code you get the default look)

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

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

index.html
<div id="app">
  <div class="toolbar">
    <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>
main.js
import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('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));
example.js
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, '');
  },
};

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

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

index.html
<div id="app">
  <div class="toolbar">
    <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>
main.js
import { createGrid } from 'maxgrid';
import { actions, options, setup } from './example';
const api = createGrid(document.getElementById('grid'), options);
setup(api, console.log);
document.getElementById('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));
example.js
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, '');
  },
};