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

필터 팝업 크기와 값 목록 꾸미기Size the filter popup and shape the value list

filterMenu의 width, height로 팝업 크기를, blankPosition으로 (비어 있음) 위치를, valueTree로 날짜 값 목록을 연>월>일 트리로 정하고, filterRowHeight로 필터 행 높이를, 컬럼의 filter.menu: false로 깔때기를 숨겨요.Set the popup size with filterMenu width and height, the empty-value position with blankPosition, turn date value lists into a year > month > day tree with valueTree, set the filter row height with filterRowHeight, and hide a funnel with filter.menu: false.

활용Intermediate
직접 써 보기Live preview필터 팝업 크기와 값 목록 꾸미기Size the filter popup and shape the value list

코드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">
    <select aria-label="팝업 너비" id="width">
      <option value="default" selected>기본</option>
      <option value="wide">480px</option>
    </select>
    <select aria-label="값 목록 높이" id="height">
      <option value="default" selected>기본</option>
      <option value="tall">360px</option>
    </select>
    <select aria-label="(비어 있음) 위치" id="blank">
      <option value="default" selected>기본(맨 아래)</option>
      <option value="first">맨 위</option>
    </select>
    <select aria-label="날짜 값 목록" id="tree">
      <option value="off" selected>평평하게</option>
      <option value="on">연>월>일 트리</option>
    </select>
    <select aria-label="필터 행 높이" id="rowHeight">
      <option value="default" selected>기본</option>
      <option value="tall">56px</option>
    </select>
  </div>
  <div id="grid" style="height: 520px"></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('width').addEventListener('change', (event) => actions.width(api, event.target.value));
document.getElementById('height').addEventListener('change', (event) => actions.height(api, event.target.value));
document.getElementById('blank').addEventListener('change', (event) => actions.blank(api, event.target.value));
document.getElementById('tree').addEventListener('change', (event) => actions.tree(api, event.target.value));
document.getElementById('rowHeight').addEventListener('change', (event) => actions.rowHeight(api, event.target.value));
example.js
const names = ['김민준', '이서연', '박지호', '최유나', '정도윤', '한소희'];
const depts = ['개발팀', '디자인팀', '영업팀', '인사팀', null];
let menu = {};
export const options = {
  filterMenu: menu,
  filterRow: true,
  columns: [
    { id: 'name', title: '이름', width: 120, filter: { menu: false } },
    { id: 'dept', title: '부서', width: 130 },
    {
      id: 'hired',
      title: '입사일',
      kind: 'date',
      width: 150,
      formatValue: (value) => (value instanceof Date ? value.toISOString().slice(0, 10) : ''),
    },
  ],
  rows: Array.from({ length: 36 }, (_, i) => ({
    id: i + 1,
    name: names[i % 6],
    dept: depts[(i * 3) % 5] ?? null,
    hired: i % 9 === 8 ? null : new Date(2022 + (i % 3), (i * 5) % 12, 3 + ((i * 7) % 24)),
  })),
  rowKey: 'id',
};
let say = () => { };
export function setup(_api, log) {
  say = log;
  menu = {};
  log({
    ko: '깔때기를 눌러 팝업 크기와 값 목록을 바꿔 보세요. 이름 컬럼은 menu: false라서 깔때기가 없고 필터 행 칸만 있어요.',
    en: 'Press a funnel and try the size and value list settings. The Name column has menu: false, so it has no funnel, only its filter row cell.',
  });
}
function set(api, patch, text) {
  menu = { ...menu, ...patch };
  api.closeFilterMenu();
  api.setOptions({ filterMenu: { ...menu } });
  say(text);
}
export const actions = {
  width: (api, value) => set(api, { width: value === 'wide' ? 480 : undefined }, {
    ko: value === 'wide' ? '팝업 너비 480px' : '팝업 너비 기본',
    en: value === 'wide' ? 'Popup width 480px' : 'Popup width default',
  }),
  height: (api, value) => set(api, { height: value === 'tall' ? 360 : undefined }, {
    ko: value === 'tall' ? '값 목록 높이 360px' : '값 목록 높이 기본',
    en: value === 'tall' ? 'Value list height 360px' : 'Value list height default',
  }),
  blank: (api, value) => set(api, { blankPosition: value === 'first' ? 'first' : undefined }, {
    ko: value === 'first' ? '(비어 있음)을 맨 위에' : '(비어 있음)은 기본 위치',
    en: value === 'first' ? 'Empty value first' : 'Empty value at the default place',
  }),
  tree: (api, value) => set(api, { valueTree: value === 'on' }, {
    ko: value === 'on' ? '입사일 값 목록이 연>월>일 트리예요' : '값 목록이 평평해요',
    en: value === 'on' ? 'Hired values are a year > month > day tree' : 'Value lists are flat',
  }),
  rowHeight: (api, value) => {
    api.setOptions({ filterRowHeight: value === 'tall' ? 56 : undefined });
    say({
      ko: value === 'tall' ? '필터 행 높이 56px' : '필터 행 높이 기본',
      en: value === 'tall' ? 'Filter row height 56px' : 'Filter row height default',
    });
  },
};

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">
    <select aria-label="Popup width" id="width">
      <option value="default" selected>Default</option>
      <option value="wide">480px</option>
    </select>
    <select aria-label="Value list height" id="height">
      <option value="default" selected>Default</option>
      <option value="tall">360px</option>
    </select>
    <select aria-label="Empty value position" id="blank">
      <option value="default" selected>Default (bottom)</option>
      <option value="first">Top</option>
    </select>
    <select aria-label="Date value list" id="tree">
      <option value="off" selected>Flat</option>
      <option value="on">Year > month > day tree</option>
    </select>
    <select aria-label="Filter row height" id="rowHeight">
      <option value="default" selected>Default</option>
      <option value="tall">56px</option>
    </select>
  </div>
  <div id="grid" style="height: 520px"></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('width').addEventListener('change', (event) => actions.width(api, event.target.value));
document.getElementById('height').addEventListener('change', (event) => actions.height(api, event.target.value));
document.getElementById('blank').addEventListener('change', (event) => actions.blank(api, event.target.value));
document.getElementById('tree').addEventListener('change', (event) => actions.tree(api, event.target.value));
document.getElementById('rowHeight').addEventListener('change', (event) => actions.rowHeight(api, event.target.value));
example.js
const names = [
  'Liam Carter',
  'Emma Stone',
  'Noah Kim',
  'Olivia Park',
  'Ethan Brooks',
  'Sophia Lee',
];
const depts = ['Dev', 'Design', 'Sales', 'HR', null];
let menu = {};
export const options = {
  filterMenu: menu,
  filterRow: true,
  columns: [
    { id: 'name', title: 'Name', width: 130, filter: { menu: false } },
    { id: 'dept', title: 'Dept', width: 130 },
    {
      id: 'hired',
      title: 'Hired',
      kind: 'date',
      width: 150,
      formatValue: (value) => (value instanceof Date ? value.toISOString().slice(0, 10) : ''),
    },
  ],
  rows: Array.from({ length: 36 }, (_, i) => ({
    id: i + 1,
    name: names[i % 6],
    dept: depts[(i * 3) % 5] ?? null,
    hired: i % 9 === 8 ? null : new Date(2022 + (i % 3), (i * 5) % 12, 3 + ((i * 7) % 24)),
  })),
  rowKey: 'id',
};
let say = () => { };
export function setup(_api, log) {
  say = log;
  menu = {};
  log('Press a funnel and try the size and value list settings. The Name column has menu: false, so it has no funnel, only its filter row cell.');
}
function set(api, patch, text) {
  menu = { ...menu, ...patch };
  api.closeFilterMenu();
  api.setOptions({ filterMenu: { ...menu } });
  say(text);
}
export const actions = {
  width: (api, value) => set(api, { width: value === 'wide' ? 480 : undefined }, value === 'wide' ? 'Popup width 480px' : 'Popup width default'),
  height: (api, value) => set(api, { height: value === 'tall' ? 360 : undefined }, value === 'tall' ? 'Value list height 360px' : 'Value list height default'),
  blank: (api, value) => set(api, { blankPosition: value === 'first' ? 'first' : undefined }, value === 'first' ? 'Empty value first' : 'Empty value at the default place'),
  tree: (api, value) => set(api, { valueTree: value === 'on' }, value === 'on' ? 'Hired values are a year > month > day tree' : 'Value lists are flat'),
  rowHeight: (api, value) => {
    api.setOptions({ filterRowHeight: value === 'tall' ? 56 : undefined });
    say(value === 'tall' ? 'Filter row height 56px' : 'Filter row height default');
  },
};