2016-11-29 103 views
0

我想将冰岛货币格式显示在kendogrid中的一个字段中。据我了解,他们的货币格式(#。###)与美元有些不同 - 例如:KendoGrid中的货币格式

$ 1,000.20将显示为1.000,截断20美分,逗号替换为句点。我也不需要网格中的货币符号。谁能帮我吗?

以下是代码片段

{ 
    field: "Discount", 
    title: "MyTotal", 
    format: "{ 0:'c' }", 
    attributes: { "class": "editable-cell", style: "text-align: right" } 
} 
+0

你有没有试过[改变你的文化](http://demos.telerik.com/kendo-ui/globalization/index)? –

+0

你到目前为止已经取得/尝试过了什么?显示您的实际+所需结果的一些图像 –

回答

0

如果一个领域的文化是不同的比整体的文化是在页面上使用,那么你将不得不使用一个自定义编辑器(http://demos.telerik.com/kendo-ui/grid/editing-custom)因为列配置不支持特定文化,但使用NumericTextBox的自定义编辑器会为您提供NumericTextBox的所有配置选项,包括文化(http://docs.telerik.com/kendo-ui/api/javascript/ui/numerictextbox#configuration)。

定义你的列,如:

columns: [ 
    { 
     field: "Discount", 
     title: "MyTotal", 
     editor: icelandicDiscountEditor, template: "#= Discount #" 
    } 

和编辑器(注意,您必须访问NumericTextBox的所有配置选项做的,只要你喜欢):

function icelandicDiscountEditor(container, options) { 
    $('<input required name="' + options.field + '"/>') 
     .appendTo(container) 
     .kendoNumericTextBox({ 
      culture: "is-IS", 
      format: "c" 
     }); 
} 

Demo of Icelandic format NumericTextBox in Grid vs "Default Culture" NumericTextBox

请注意,为了使用“is-IS”文化,您还必须在页面中加载kendo文化JS脚本,否则文化配置将被忽略,默认仍然会被使用。

如果该字段的文化与页面上其他地方的文化相同,只需将kendo.culture()设置为Sunny Patel所建议的。