Set custom thousand seperator in Column Format

Is there a way to define the Thousand seperator for numbers in the grid? For example - you might want to switch from dot to comma or vice versa.


1 Reply

JC Joseph Christ Nithin Issack Syncfusion Team February 4, 2022 12:58 PM UTC

Hi Sebastian, 

  Greetings from Syncfusion Support. 

  Based on your query, you want to display the numbers with `.`  as the thousand separator for the numbers. Your requirement can be achieved using the `queryCellInfo` event of the Ej2 Grid.  

Please refer the below code example. 


let gridGrid = 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: 120format: '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.'); 
} 
 




Please get back to us for further details. 

Regards, 
Joseph I. 


Loader.
Up arrow icon