JavaScript
const salesData = [
{ id: 1, name: '김지영', category: '소프트웨어', amount: 1500000, status: '진행중' },
{ id: 2, name: '이민준', category: '하드웨어', amount: 870000, status: '완료' },
{ id: 3, name: '박서연', category: '컨설팅', amount: 2300000, status: '진행중' },
{ id: 4, name: '최준혁', category: '소프트웨어', amount: 650000, status: '완료' },
{ id: 5, name: '정하은', category: '하드웨어', amount: 1100000, status: '진행중' },
];
const statusMsg = document.getElementById('statusMsg');
const grid = new wijmo.grid.FlexGrid('#salesGrid', {
itemsSource: salesData,
columns: [
{ binding: 'id', header: 'ID', isReadOnly: true, width: 60 },
{ binding: 'name', header: '담당자', width: 130 },
{ binding: 'category', header: '카테고리', width: 140 },
{ binding: 'amount', header: '매출액 (원)', format: 'n0', width: 150 },
{ binding: 'status', header: '상태', isReadOnly: true, width: 90 },
]
});
grid.beginningEdit.addHandler(function(sender, args) {
const item = sender.rows[args.row].dataItem;
if (item && item.status === '완료') {
args.cancel = true;
statusMsg.textContent = '⚠ 완료된 항목은 수정할 수 없습니다.';
} else {
statusMsg.textContent = '';
}
});
grid.cellEditEnded.addHandler(function(sender, args) {
const val = sender.getCellData(args.row, args.col, true);
statusMsg.textContent = '✔ 저장됨: ' + val;
});