const { createApp, ref, onMounted } = Vue;
createApp({
setup() {
const gridHost = ref(null);
const statusMsg = ref('');
function generateData() {
const countries = ['대한민국', '미국', '일본', '독일', '프랑스'];
return countries.map((country, i) => ({
id: i + 1,
country,
sales: Math.round(Math.random() * 10000),
expenses: Math.round(Math.random() * 5000),
active: i % 2 === 0
}));
}
onMounted(() => {
const grid = new wijmo.grid.FlexGrid(gridHost.value, {
itemsSource: generateData(),
autoGenerateColumns: false,
columns: [
{ binding: 'id', header: '번호', width: 60, isReadOnly: true },
{ binding: 'country', header: '국가', width: 120 },
{ binding: 'sales', header: '매출', format: 'n0', width: 100 },
{ binding: 'expenses', header: '비용', format: 'n0', width: 100 },
{ binding: 'active', header: '활성', width: 80 }
]
});
grid.autoSizeColumns();
statusMsg.value = `FlexGrid 초기화 완료 — ${grid.rows.length}행 로드됨`;
});
return { gridHost, statusMsg };
},
template: `
<div style="padding:16px;font-family:sans-serif;">
<h3 style="margin-top:0;">영업 실적 데이터</h3>
<p v-if="statusMsg" style="color:#4caf50;margin:0 0 8px;">{{ statusMsg }}</p>
<div ref="gridHost" style="max-height:300px;"></div>
</div>
`
}).mount('#app');