JSX
import React, { useState } from 'react';
import * as wjcCore from '@mescius/wijmo';
import * as wjcGrid from '@mescius/wijmo.react.grid';
import '@mescius/wijmo.styles/wijmo.css';
import '@mescius/wijmo.cultures/wijmo.culture.ko'; // 한국어 문화권 — 날짜·숫자·필터 UI 한글화
wjcCore.setLicenseKey('YOUR_LICENSE_KEY');
function getData() {
const regions = ['서울', '부산', '대구', '인천', '광주'];
const categories = ['전자제품', '의류', '식품', '가구', '스포츠'];
return Array.from({ length: 15 }, (_, i) => ({
id: i + 1,
region: regions[i % regions.length],
category: categories[i % categories.length],
revenue: Math.round(Math.random() * 10000 + 1000),
cost: Math.round(Math.random() * 5000 + 500),
date: new Date(2026, i % 12, (i % 28) + 1),
isApproved: i % 2 === 0,
}));
}
export default function App() {
const [data] = useState(getData());
const [selectedItem, setSelectedItem] = useState(null);
return (
<div style={{ padding: '16px', fontFamily: 'sans-serif' }}>
<h3>지역별 매출 현황</h3>
{/*
중요: autoGenerateColumns={false}를 먼저 선언해야
FlexGridColumn 정의가 자동 컬럼 생성보다 우선 적용됨
*/}
<wjcGrid.FlexGrid
autoGenerateColumns={false}
itemsSource={data}
style={{ height: '320px' }}
>
{/* binding: 데이터 객체 키 / header: 표시할 헤더 문자열 */}
<wjcGrid.FlexGridColumn binding="id" header="번호" width={60} isReadOnly={true} />
<wjcGrid.FlexGridColumn binding="region" header="지역" width={80} />
<wjcGrid.FlexGridColumn binding="category" header="카테고리" width={100} />
{/* format="n0": 천 단위 콤마, 소수점 없음 */}
<wjcGrid.FlexGridColumn binding="revenue" header="매출액" width={110} format="n0" />
<wjcGrid.FlexGridColumn binding="cost" header="비용" width={100} format="n0" />
{/* format="yyyy-MM-dd": 날짜 표시 형식 */}
<wjcGrid.FlexGridColumn binding="date" header="날짜" width={120} format="yyyy-MM-dd" />
<wjcGrid.FlexGridColumn binding="isApproved" header="승인 여부" width={90} />
</wjcGrid.FlexGrid>
</div>
);
}