Kendo ui 设置剑道网格的格式以显示美元符号并允许最多两位小数?

Kendo ui 设置剑道网格的格式以显示美元符号并允许最多两位小数?,kendo-ui,kendo-grid,Kendo Ui,Kendo Grid,我创建了一个剑道网格,如下所示: function drawInvoiceTable() { invoiceTable = $('#invoiceGrid').kendoGrid({ sortable: true, pageable: true, dataSource: { data: getData(), pageSize: 10, schema: {

我创建了一个剑道网格,如下所示:

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();
}
函数drawInvoiceTable(){
invoiceTable=$(“#invoiceGrid”).kendoGrid({
可排序:是的,
pageable:对,
数据源:{
数据:getData(),
页面大小:10,
模式:{
型号:{
id:'测试',
字段:{
活动:错误
}
}
}
},
栏目:[
{模板:“”,宽度:30},
{字段:'accountNumber',标题:'Account',属性:{'class':'accountNumber'},可排序:true},
{字段:'transactionDate',标题:'Trans-Date',属性:{'class':'transdate'},宽度:100,可排序:true},
{字段:'TransType',标题:'Type',属性:{'class':'TransType'},宽度:60,可排序:true},
{字段:'TransReferenceNumber',标题:'Reference Number',属性:{'class':'refnumber'},宽度:135,可排序:true},
{字段:'transactionDebitAmount',标题:'Amount',属性:{'class':'Amount'},宽度:90,可排序:true},
{字段:'openBalance',标题:'Balance',宽度:90,属性:{'class':'Balance'},模板:'#=kendo.format(“{0:p}”,openBalance)#',可排序:true},
{字段:'discountAmount',标题:'Discount',格式:{0:c},属性:{'class':'Discount',数据格式:'c'},宽度:90,可排序:false},
{字段:'discountApplied',标题:'discountApplied',宽度:95,属性:{'class':'Discpapplied'},可排序:false},
{字段:'paymentApplied',标题:'paymentApplied',宽度:95,属性:{'class':'paymentApplied'},可排序:false},
{字段:“折扣日期”,标题:“折扣日期”,属性:{“类”:“折扣日期”},
{字段:'dueDate',标题:'Due Date',宽度:90,可排序:true}
]
});
网格=$('#invoiceGrid')。数据('kendoGrid');
dataSource=grid.dataSource;
data=dataSource.data();
}

如何将某些列中的值格式化为美元符号,并允许最多2位小数,如$12541.23?

在列定义中使用
格式:“{0:c2}”

c
代表货币,
2
是小数位数

您希望将设置为
“{0:c2}”

“c2”是数字格式(货币,小数点后2位)。

我尝试了您上面的建议,但仍然没有成功。请查看我的JSFIDLE,您需要说明字段的类型为
number
。有关修改的
discountAmount
(和其他字段),请参见此处。是否有这些格式字符串的文档?找不到任何文件如果有人仍然需要格式化文档,可以在建议的链接下找到。我尝试了你上面的建议,但仍然没有成功。请看我的手指
{ field:"price", title:"Price", format:"{0:c2}" },