빠른 검색
보이는 모든 컬럼을 한 칸으로 검색: 낱말이 모두 맞아야 하고, "구절"은 그대로, -낱말은 제외, 초성과 옵션 이름도 찾습니다.
실행 예제빠른 검색
모든 컬럼에서 낱말, "구절", -제외.
이 데모의 코드
import { createGrid, type ColumnDef, type Row } from '@freegridjs/core';
import { makeRows } from '../data';
import { button, separator, text, tr, type DemoContext } from '../ui';
export default function mount(ctx: DemoContext) {
const h = (en: string, ko: string) => tr(ctx.lang, { en, ko });
const grid = createGrid(ctx.host, {
columns: [
{ field: 'name', header: h('Name', '이름'), width: 170 }, { field: 'company', header: h('Company', '회사'), width: 160 },
{ field: 'country', header: h('Country', '국가'), width: 140 }, { field: 'status', header: h('Status', '상태'), width: 110 },
{ field: 'q1', header: h('Q1', '1분기'), type: 'number', format: '#,##0', width: 110 },
],
data: makeRows(5000), locale: ctx.lang,
});
const box = document.createElement('input');
box.type = 'search';
box.placeholder = h('kim japan · "emma smith" · japan -active', 'kim japan · "emma smith" · japan -active');
box.addEventListener('input', () => { grid.setQuickFilter(box.value); ctx.log(`"${box.value}" → ${grid.getDisplayedRowCount()} rows`); });
ctx.controls.append(box);
separator(ctx);
for (const s of ['kim japan', '"emma smith"', 'japan -active', 'pending -japan']) button(ctx, s, () => { box.value = s; box.dispatchEvent(new Event('input')); });
return grid;
}setQuickFilter(text)는 보이는 모든 컬럼을 한 번에 검색해 행을 거릅니다. 그리드 위에 흔히 두는 검색칸이고, 컬럼 필터·고급 필터와 함께 동작합니다.
const box = document.querySelector('#search');
box.addEventListener('input', () => grid.setQuickFilter(box.value));입력 문법
| 입력 | 뜻 |
|---|---|
| kim seoul | kim 과 seoul이 모두 들어 있는 행(컬럼은 상관없음) |
| "seoul office" | 구절 그대로(낱말이 붙어 있어야 함) |
| seoul -closed | seoul이 있고 closed가 없는 행 |
| -"on hold" | 그 구절이 없는 행 |
| ㄱㅎ | 한글 초성(김하늘) |
검색 대상
- 보이는 모든 컬럼의 글자를 화면에 보이는 대로: 서식이 적용된 숫자·날짜, 코드 대신 옵션 이름, 여러 값 이름, 기간.
- 전화번호 같은 서식 값은 숫자만으로도(
01012). - 숨긴 컬럼과 행 번호·체크박스 같은 시스템 컬럼은 검색하지 않습니다.
- 대소문자는 구분하지 않습니다.
상태와 서버
getState()에 들어가고(quickFilter),stateParts에 넣으면stateKey로 유지됩니다.- datasource일 때 글자가 그대로
getRows의quickFilter로 가고, 서버 예제는 텍스트 컬럼에서 검색합니다. - 행을 숨기지 않고 일치한 셀만 표시하려면 찾기를 쓰세요.