데이터에서 컬럼 자동으로 만들기Build columns from the data
columns를 비우고 autoColumns를 켜면 첫 행들의 키로 컬럼을 만들고 값을 보고 숫자·날짜·참거짓 종류를 정해요. exclude로 뺄 키를 고르고 template으로 공통 정의를 덮어요.Leave columns empty and set autoColumns to build columns from the keys of the first rows, with number, date or boolean kinds inferred from the values. exclude drops keys and template adds shared settings.
코드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 id="grid" style="height: 260px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { options } from './example';
const api = createGrid(document.getElementById('grid'), options);const names = ['김민준', '이서연', '박도윤', '최하은', '정시우'];
// 컬럼을 비워 두고 autoColumns를 켜면 첫 행들의 키로 컬럼이 만들어져요. 종류(숫자·날짜·참거짓)는 값을 보고 정해요.
// exclude로 뺄 키를 고르고, template으로 만든 컬럼에 같은 정의를 덮어요. 하위 객체는 점 경로 키('address.city')로 읽어요.
export const options = {
columns: [],
autoColumns: { exclude: ['id', 'address'], template: { width: 120 } },
rows: names.map((name, i) => ({
id: i + 1,
name,
joined: `2026-0${(i % 9) + 1}-1${i}`,
active: i % 2 === 0,
score: 60 + i * 8,
address: { city: ['서울', '부산', '대전'][i % 3] },
})),
rowKey: 'id',
};<!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 id="grid" style="height: 260px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const names = ['김민준', '이서연', '박도윤', '최하은', '정시우'];
// 컬럼을 비워 두고 autoColumns를 켜면 첫 행들의 키로 컬럼이 만들어져요. 종류(숫자·날짜·참거짓)는 값을 보고 정해요.
// exclude로 뺄 키를 고르고, template으로 만든 컬럼에 같은 정의를 덮어요. 하위 객체는 점 경로 키('address.city')로 읽어요.
const options = {
columns: [],
autoColumns: { exclude: ['id', 'address'], template: { width: 120 } },
rows: names.map((name, i) => ({
id: i + 1,
name,
joined: `2026-0${(i % 9) + 1}-1${i}`,
active: i % 2 === 0,
score: 60 + i * 8,
address: { city: ['서울', '부산', '대전'][i % 3] },
})),
rowKey: 'id',
};
options.ariaLabel = "데이터에서 컬럼 자동으로 만들기";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
</script>
</body>
</html>버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Grid } from '@maxgrid/react';
import { options, type Row } from './example';
export function ExampleGrid() {
return (
<>
<Grid style={{ height: 260 }} options={options} />
</>
);
}import type { GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
name: string;
joined: string;
active: boolean;
score: number;
address: { city: string };
}
const names = ['김민준', '이서연', '박도윤', '최하은', '정시우'];
// 컬럼을 비워 두고 autoColumns를 켜면 첫 행들의 키로 컬럼이 만들어져요. 종류(숫자·날짜·참거짓)는 값을 보고 정해요.
// exclude로 뺄 키를 고르고, template으로 만든 컬럼에 같은 정의를 덮어요. 하위 객체는 점 경로 키('address.city')로 읽어요.
export const options: GridOptions<Row> = {
columns: [],
autoColumns: { exclude: ['id', 'address'], template: { width: 120 } },
rows: names.map((name, i) => ({
id: i + 1,
name,
joined: `2026-0${(i % 9) + 1}-1${i}`,
active: i % 2 === 0,
score: 60 + i * 8,
address: { city: ['서울', '부산', '대전'][i % 3] as string },
})),
rowKey: 'id',
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
<script setup lang="ts">
import { Grid } from '@maxgrid/vue';
import { options, type Row } from './example';
</script>
<template>
<Grid style="height: 260px" :options="options" />
</template>import type { GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
name: string;
joined: string;
active: boolean;
score: number;
address: { city: string };
}
const names = ['김민준', '이서연', '박도윤', '최하은', '정시우'];
// 컬럼을 비워 두고 autoColumns를 켜면 첫 행들의 키로 컬럼이 만들어져요. 종류(숫자·날짜·참거짓)는 값을 보고 정해요.
// exclude로 뺄 키를 고르고, template으로 만든 컬럼에 같은 정의를 덮어요. 하위 객체는 점 경로 키('address.city')로 읽어요.
export const options: GridOptions<Row> = {
columns: [],
autoColumns: { exclude: ['id', 'address'], template: { width: 120 } },
rows: names.map((name, i) => ({
id: i + 1,
name,
joined: `2026-0${(i % 9) + 1}-1${i}`,
active: i % 2 === 0,
score: 60 + i * 8,
address: { city: ['서울', '부산', '대전'][i % 3] as string },
})),
rowKey: 'id',
};버튼을 누르면 이 예제의 코드가 StackBlitz나 CodeSandbox로 전송돼요. 누르기 전에는 아무것도 보내지 않아요.
import { Component } from '@angular/core';
import { GridComponent } from '@maxgrid/angular';
import { options, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<mx-grid style="height: 260px" [options]="options" />
`,
})
export class ExampleGridComponent {
readonly options = options;
}import type { GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
name: string;
joined: string;
active: boolean;
score: number;
address: { city: string };
}
const names = ['김민준', '이서연', '박도윤', '최하은', '정시우'];
// 컬럼을 비워 두고 autoColumns를 켜면 첫 행들의 키로 컬럼이 만들어져요. 종류(숫자·날짜·참거짓)는 값을 보고 정해요.
// exclude로 뺄 키를 고르고, template으로 만든 컬럼에 같은 정의를 덮어요. 하위 객체는 점 경로 키('address.city')로 읽어요.
export const options: GridOptions<Row> = {
columns: [],
autoColumns: { exclude: ['id', 'address'], template: { width: 120 } },
rows: names.map((name, i) => ({
id: i + 1,
name,
joined: `2026-0${(i % 9) + 1}-1${i}`,
active: i % 2 === 0,
score: 60 + i * 8,
address: { city: ['서울', '부산', '대전'][i % 3] as string },
})),
rowKey: 'id',
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<div id="app">
<div id="grid" style="height: 260px"></div>
</div>
<script type="module" src="./main.js"></script>import { createGrid } from 'maxgrid';
import { options } from './example';
const api = createGrid(document.getElementById('grid'), options);const names = ['Liam Carter', 'Emma Stone', 'Noah Hayes', 'Olivia Reed', 'Ethan Cole'];
// Leave columns empty and turn on autoColumns: columns are built from the keys of the first rows. The kind (number, date, boolean) is inferred from the values.
// exclude picks the keys to leave out, and template applies the same definition to every built column. Nested objects are read with dot-path keys ('address.city').
export const options = {
columns: [],
autoColumns: { exclude: ['id', 'address'], template: { width: 120 } },
rows: names.map((name, i) => ({
id: i + 1,
name,
joined: `2026-0${(i % 9) + 1}-1${i}`,
active: i % 2 === 0,
score: 60 + i * 8,
address: { city: ['Seattle', 'Boston', 'Denver'][i % 3] },
})),
rowKey: 'id',
};<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Build columns from the data</title>
</head>
<body>
<div id="grid" style="height: 260px"></div>
<script src="https://cdn.maxmine.com/maxgrid/latest/maxgrid.min.js"></script>
<script>
const names = ['Liam Carter', 'Emma Stone', 'Noah Hayes', 'Olivia Reed', 'Ethan Cole'];
// Leave columns empty and turn on autoColumns: columns are built from the keys of the first rows. The kind (number, date, boolean) is inferred from the values.
// exclude picks the keys to leave out, and template applies the same definition to every built column. Nested objects are read with dot-path keys ('address.city').
const options = {
columns: [],
autoColumns: { exclude: ['id', 'address'], template: { width: 120 } },
rows: names.map((name, i) => ({
id: i + 1,
name,
joined: `2026-0${(i % 9) + 1}-1${i}`,
active: i % 2 === 0,
score: 60 + i * 8,
address: { city: ['Seattle', 'Boston', 'Denver'][i % 3] },
})),
rowKey: 'id',
};
options.ariaLabel = "Build columns from the data";
const api = MaxGrid.createGrid(document.getElementById('grid'), options);
</script>
</body>
</html>When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Grid } from '@maxgrid/react';
import { options, type Row } from './example';
export function ExampleGrid() {
return (
<>
<Grid style={{ height: 260 }} options={options} />
</>
);
}import type { GridOptions } from '@maxgrid/react';
export interface Row {
id: number;
name: string;
joined: string;
active: boolean;
score: number;
address: { city: string };
}
const names = ['Liam Carter', 'Emma Stone', 'Noah Hayes', 'Olivia Reed', 'Ethan Cole'];
// Leave columns empty and turn on autoColumns: columns are built from the keys of the first rows. The kind (number, date, boolean) is inferred from the values.
// exclude picks the keys to leave out, and template applies the same definition to every built column. Nested objects are read with dot-path keys ('address.city').
export const options: GridOptions<Row> = {
columns: [],
autoColumns: { exclude: ['id', 'address'], template: { width: 120 } },
rows: names.map((name, i) => ({
id: i + 1,
name,
joined: `2026-0${(i % 9) + 1}-1${i}`,
active: i % 2 === 0,
score: 60 + i * 8,
address: { city: ['Seattle', 'Boston', 'Denver'][i % 3] as string },
})),
rowKey: 'id',
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
<script setup lang="ts">
import { Grid } from '@maxgrid/vue';
import { options, type Row } from './example';
</script>
<template>
<Grid style="height: 260px" :options="options" />
</template>import type { GridOptions } from '@maxgrid/vue';
export interface Row {
id: number;
name: string;
joined: string;
active: boolean;
score: number;
address: { city: string };
}
const names = ['Liam Carter', 'Emma Stone', 'Noah Hayes', 'Olivia Reed', 'Ethan Cole'];
// Leave columns empty and turn on autoColumns: columns are built from the keys of the first rows. The kind (number, date, boolean) is inferred from the values.
// exclude picks the keys to leave out, and template applies the same definition to every built column. Nested objects are read with dot-path keys ('address.city').
export const options: GridOptions<Row> = {
columns: [],
autoColumns: { exclude: ['id', 'address'], template: { width: 120 } },
rows: names.map((name, i) => ({
id: i + 1,
name,
joined: `2026-0${(i % 9) + 1}-1${i}`,
active: i % 2 === 0,
score: 60 + i * 8,
address: { city: ['Seattle', 'Boston', 'Denver'][i % 3] as string },
})),
rowKey: 'id',
};When you click, the example code is sent to StackBlitz or CodeSandbox. Nothing is sent before you click.
import { Component } from '@angular/core';
import { GridComponent } from '@maxgrid/angular';
import { options, type Row } from './example';
@Component({
selector: 'app-example-grid',
standalone: true,
imports: [GridComponent],
template: `
<mx-grid style="height: 260px" [options]="options" />
`,
})
export class ExampleGridComponent {
readonly options = options;
}import type { GridOptions } from '@maxgrid/angular';
export interface Row {
id: number;
name: string;
joined: string;
active: boolean;
score: number;
address: { city: string };
}
const names = ['Liam Carter', 'Emma Stone', 'Noah Hayes', 'Olivia Reed', 'Ethan Cole'];
// Leave columns empty and turn on autoColumns: columns are built from the keys of the first rows. The kind (number, date, boolean) is inferred from the values.
// exclude picks the keys to leave out, and template applies the same definition to every built column. Nested objects are read with dot-path keys ('address.city').
export const options: GridOptions<Row> = {
columns: [],
autoColumns: { exclude: ['id', 'address'], template: { width: 120 } },
rows: names.map((name, i) => ({
id: i + 1,
name,
joined: `2026-0${(i % 9) + 1}-1${i}`,
active: i % 2 === 0,
score: 60 + i * 8,
address: { city: ['Seattle', 'Boston', 'Denver'][i % 3] as string },
})),
rowKey: 'id',
};