巧用kendo.format和kendo.toString 格式化0为空格(不显示)
来源:互联网 发布:淘宝时间护照的表真吗 编辑:程序博客网 时间:2024/06/10 03:40
一般格式:
kendo.format("{0:0.00}", 5) // 5.00
kendo.format("{0:0.00}", -5) // -5.00
kendo.format("{0:0.##}", -5) // -5
kendo.format("{0:0.##}", -5.00)// -5
带千位符(,)
kendo.format("{0:#,0.00}", 5000.00) // 5,000.00
kendo.format("{0:#,0.##}", 5000.00) // 5,000
kendo.format("{0:#,0.##}", 5000.123) // 5,000.12
kendo.format("{0:#,#.##}", 5000.123) // 5,000.12
0(零)不显示。
注意:用分号(;)分成3段,如: {0:正数格式;负数格式;零格式}
kendo.format("{0:#,#.00;-#,#.00; }", 5000.123) // 5,000.12
kendo.format("{0:#,#.00;-#,#.00; }", -5000.123 // -5,000.12
kendo.format("{0:#,#.00;-#,#.00; }", 0) // 空格 (注意:第3段的“空格”不要漏了)
如果想了解更多,可以看Kendo API
http://docs.telerik.com/kendo-ui/api/javascript/kendo#methods-format
http://docs.telerik.com/kendo-ui/framework/globalization/numberformatting 底部有这一行
"The ";"
is the section separator. It defines sections with separate format strings for positive, negative, and zero numbers."
说明用kendo.toString也可以实现类似效果:
kendo.toString(5000.123, "#,#.##;-#,#.00; ") // 5,000.12
kendo.toString(-5000.123, "#,#.##;-#,#.00; ") // -5,000.12
kendo.toString(0, "#,#.##;-#,#.00; ") // 空格 (注意:第3段的“空格”不要漏了)
- 巧用kendo.format和kendo.toString 格式化0为空格(不显示)
- kendo
- Kendo Column Format Date
- kendo grid序号显示
- kendo Window 设置居中显示
- kendo Window 设置居中显示
- Kendo Grid bit(布尔型/逻辑型)显示方法
- kendo ComboBox显示多列数据(自定义样式)
- kendo grid显示行号/序号列(二)
- 解决Kendo ComboBox显示多列走样 (备忘)
- Kendo UI:Grid中单元格日期格式化
- Kendo自定义组件(强烈推荐)
- .NET ToString() format格式化字符串(常用)
- Kendo 锁定元素并显示加载动画
- kendo DatePicker 之 设置为中文格式
- kendo DatePicker 之 设置为中文格式
- kendo控件
- Kendo DataSource
- python的字符串操作
- 渐变效果
- oracle 远程访问数据库 ORA-01034和ORA-27101问题的一种解决方法
- 二叉树的最大深度
- Leetcode Java-Combination Sum
- 巧用kendo.format和kendo.toString 格式化0为空格(不显示)
- struts2值栈
- 8-32 判断一棵二叉树是否是完全二叉树
- typeof()和instanceof()用法
- unity webgl 初学者1
- 2120 数据结构实验之链表五:单链表的拆分
- 假日指南!实用API带你出行~
- Ubuntu下使用VI编辑文件必知的常用命令
- leetcode 309. Best Time to Buy and Sell Stock with Cooldown 动态规划DP