2015-10-20 226 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天我搜索解決方案^^。 –