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以显示美元符号并允许最多两位小数?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- awk中符点型小数去掉小数点转换成整数的方法
- objective-c – NSDecimalNumber的小数部分
- 可以在MySQL中存储小数(22,2)的钱吗?
- 正则表达式判定保留2位小数的实现代码
- 在JSP中使用formatNumber控制要显示的小数位数方法
- 代码片段之jQuery控制input只能输入数字和两位小数
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Code Reading
Diomidis Spinellis / Addison-Wesley Professional / 2003-06-06 / USD 64.99
This book is a unique and essential reference that focuses upon the reading and comprehension of existing software code. While code reading is an important task faced by the vast majority of students,......一起来看看 《Code Reading》 这本书的介绍吧!