kendo-ui – 格式化Kendo Grid以显示美元符号并允许最多两位小数?

栏目: JavaScript · 发布时间: 7年前

内容简介:翻译自:https://stackoverflow.com/questions/18728811/format-kendo-grid-to-display-dollars-sign-and-allow-up-to-two-decimal

我有一个我创建的kendo Grid,如下所示:

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();
}

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

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

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

c代表货币,2代表小数

翻译自:https://stackoverflow.com/questions/18728811/format-kendo-grid-to-display-dollars-sign-and-allow-up-to-two-decimal


以上所述就是小编给大家介绍的《kendo-ui – 格式化Kendo Grid以显示美元符号并允许最多两位小数?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

社群运营五十讲

社群运营五十讲

陈菜根 / 北京时代华文书局 / 2018-4-1 / 49.80

物以类聚,人以群分,社群营销不只是简单的建群、卖东西,而是建立一种自动运转的,去中心化的生态圈,让相同爱好的人产生关系,迸发出裂变的火花,创造更多的营销机会。本书从基本的社群概念入手,讲解了社群的五大要素,社群活动的运作,社群的变现模式以及如何做一个社群师等内容,最后再从如何打造社群IP入手,详细讲解了社群IP的定义、分类及操作过程。一起来看看 《社群运营五十讲》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器