let grid: Grid = new Grid({
dataSource: data,
queryCellInfo: (args) => {
if (args.column.field == 'OrderID') {
args.cell.innerHTML = formatNumber(args.data['OrderID']);
}
},
columns: [
{
field: 'OrderID',
headerText: 'Order ID',
width: 120,
textAlign: 'Right',
},
{ field: 'CustomerName', headerText: 'Customer Name', width: 150 },
{
field: 'OrderDate',
headerText: 'Order Date',
width: 130,
format: 'yMd',
textAlign: 'Right',
},
{ field: 'Freight', width: 120, format: 'C2', textAlign: 'Right' },
{
field: 'ShippedDate',
headerText: 'Shipped Date',
width: 140,
format: 'yMd',
textAlign: 'Right',
},
{ field: 'ShipCountry', headerText: 'Ship Country', width: 150 },
],
});
grid.appendTo('#Grid');
function formatNumber(num) {
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1.');
}
|