Kendo Grid format for displaying a dollar sign and resolution up to two decimal places?

I have a kendo grid that I create as follows:

function drawInvoiceTable() { invoiceTable = $('#invoiceGrid').kendoGrid({ sortable: true, pageable: true, dataSource: { data: getData(), pageSize: 10, schema: { model: { id: 'test', fields: { active: false } } } }, columns: [ { template: "<input type='checkbox' id='chkInvoices' class='invoiceDisplay' name='chkInvoices' #= active ? checked='checked' : '' #/>", width: 30 }, { field: 'accountNumber', title: 'Account', attributes: { 'class': 'accountnumber' }, sortable: true }, { field: 'transactionDate', title: 'Trans Date', attributes: { 'class': 'transdate' }, width: 100, sortable: true }, { field: 'TransType', title: 'Type', attributes: { 'class': 'transType' }, width: 60, sortable: true }, { field: 'TransReferenceNumber', title: 'Reference Number', attributes: { 'class': 'refnumber' }, width: 135, sortable: true }, { field: 'transactionDebitAmount', title: 'Amount', attributes: { 'class': 'amount' }, width: 90, sortable: true }, { field: 'openBalance', title: 'Balance', width: 90, attributes: { 'class': 'balance' }, template: '#= kendo.format("{0:p}", openBalance) #', sortable: true }, { field: 'discountAmount', title: 'Discount', format: "{0:c}", attributes: { 'class': 'discount', 'data-format': 'c' }, width: 90, sortable: false }, { field: 'discountApplied', title: 'Discount Applied', width: 95, attributes: { 'class': 'discapplied' }, sortable: false }, { field: 'paymentApplied', title: 'Payment Applied' , width: 95, attributes: { 'class': 'paymentapplied' }, sortable: false }, { field: 'discountDate', title: 'Discount Date', attributes: { 'class': 'discountDate' } }, { field: 'dueDate', title: 'Due Date', width: 90, sortable: true } ] }); grid = $('#invoiceGrid').data('kendoGrid'); dataSource = grid.dataSource; data = dataSource.data(); } 

How can I get the values ​​in some of my columns formatted with a dollar sign and allow up to 2 decimal places, for example $ 12541.23? strong text

+6
source share
2 answers

In the column definition, use format: "{0:c2}" :

 { field:"price", title:"Price", format:"{0:c2}" }, 

c is the currency, and 2 is the number of decimal places

+21
source

You want to set column.format to "{0:c2}" "c2" is the number format (currency, 2 decimal places) that is defined here .

0
source

Source: https://habr.com/ru/post/953591/


All Articles