2015-10-20 148 views
1

我想为像“1 000 000,00”这样的数字创建一个NumericTextBox格式。 我在ASP.NET MVC中使用Kendo,我不明白如何将千位分隔符像逗号一样更改为空格。 有我在JavaScript中的特定类的代码。使用千位分隔符的空格

代码:强大的文本

$("#XXXXXX").kendoNumericTextBox({ 
     format: "#&nbsp#",  
     decimals: 0, 
     min: 0, 
     max: 9999, 
     spinners: false, 
     value: XXXXXXXX 
    }).addClass("nombre").attr('maxlength', '4'); 

我希望你能帮助我。 非常感谢。

回答

1

小数点分隔符和组分隔符来自当前的剑道文化,它们不能直接设置为kendoNumericTextBox作为选项。但是,您可以更改相应的文化值,但要小心,因为这可能也会影响其他剑道小部件。

下面是一个例子:

// Setting the string that separates the number groups 
kendo.cultures.current.numberFormat[","] = ' '; 

// Setting the string that separates a number from the fractional point  
kendo.cultures.current.numberFormat["."] = ','; 

$('#myInput').kendoNumericTextBox();  

这里是一个JsFiddle Demo

注意:您可以创建自定义剑道文化和按名称传递剑道数字 - $('#input').kendoNumericTextBox({ culture: 'custom' });

+0

你好,我想你的解决方案,但我不能使用kendo.cultures.numberofrmat,因为我没有这个文件在我的剑道包。 我创建了一个自定义文化并导入它,但空白空间不起作用。 你知道另一种解决方案吗? –

+0

@RomannVEGUER分离文件中没有任何内容。 'kendo.core'有一个默认的文化定义。只需在你的JavaScript'kendo.cultures.current.numberFormat [“,”] ='';'中输入这个地方。请注意,它不是kendo.cultures.numberofrmat,而是kendo.cultures。** current **。numberofrmat。 –

+0

谢谢你,它的作品。你拯救了我的生命,这是3天我搜索解决方案^^。 –