JSX
import React from 'react';
import * as wjGrid from '@mescius/wijmo.react.grid';
import '@mescius/wijmo.styles/wijmo.css';
const employees = [
{ name: '김민준', department: '개발팀', salary: 85000, active: true, hireDate: new Date(2020, 2, 15) },
{ name: '이서연', department: '마케팅', salary: 72000, active: true, hireDate: new Date(2019, 5, 1) },
{ name: '박지호', department: '개발팀', salary: 91000, active: false, hireDate: new Date(2018, 0, 10) },
{ name: '최수아', department: '인사팀', salary: 68000, active: true, hireDate: new Date(2021, 8, 20) },
{ name: '정도윤', department: '영업팀', salary: 78000, active: true, hireDate: new Date(2020, 11, 5) },
];
function App() {
return (
<wjGrid.FlexGrid
autoGenerateColumns={false}
itemsSource={employees}
selectionMode="Row"
isReadOnly={true}
style={{ height: '320px' }}
>
{/* RowHeader: FlexGrid 직속 자식 */}
<wjGrid.FlexGridCellTemplate
cellType="RowHeader"
template={(context) => context.row.index + 1}
/>
<wjGrid.FlexGridColumn binding="name" header="이름" width={120} />
<wjGrid.FlexGridColumn binding="department" header="부서" width={120} />
<wjGrid.FlexGridColumn binding="salary" header="연봉" format="n0" width={130} />
{/* 재직 컬럼: Cell 타입 배지 */}
<wjGrid.FlexGridColumn binding="active" header="재직" width={100}>
<wjGrid.FlexGridCellTemplate
cellType="Cell"
template={(context) => (
<span style={{
padding: '2px 10px',
borderRadius: '12px',
backgroundColor: context.item.active ? '#4caf50' : '#9e9e9e',
color: '#fff',
fontSize: '12px',
}}>
{context.item.active ? '재직' : '퇴직'}
</span>
)}
/>
</wjGrid.FlexGridColumn>
<wjGrid.FlexGridColumn binding="hireDate" header="입사일" format="yyyy-MM-dd" width={150} />
</wjGrid.FlexGrid>
);
}
export default App;