asp.net-mvckendo-uikendo-ui-mvc

How to manually set : kendo-ui numerictextbox's currency


I have that numerictextbox which shows amount with currency. I wanna display my Model's currency but that numerictextbox always shows culture's currency. For exp. If I change website's language German then this textbox shows "€". How can I display my Model's currency instead of culture's currency? Or maybe is there a way to set numerictextbox's culture to currency's culture?

@(Html.Kendo().NumericTextBox<decimal>()
    .Name("amount")
    .Min(Model.MinPrice)       
    .Value(Model.MinPrice)
    .Format(Strings.ResourceManager.GetString(Model.Currency.ToString()) + " #.00")
    .HtmlAttributes(new { style = "width: 104px;" })
)

Also when I view-source the page it shows that:

jQuery(function(){jQuery("#Amount").kendoNumericTextBox({"format":"$ #.00"});});

But in the page it shows "€"(current culture's currency) instead of $

Anyone has same problem this is working version:

<script>
    var currCulture = kendo.culture();
    currCulture.numberFormat.currency.symbol = '@Strings.ResourceManager.GetString(Model.Currency.ToString())';
</script>

@(Html.Kendo().NumericTextBox<decimal>()
     .Name("TicketOptions[" + i + "].Price")
     .Min(memberTicketOptions[i].MinPrice)
     .Value(memberTicketOptions[i].MinPrice)
     .Format(Strings.ResourceManager.GetString(Model.Currency.ToString()) + " #.00")
     .HtmlAttributes(new { style = "width: 104px;" })
 )

Solution

  • You would need to change the current currency smybol inside kendos culture, before initializing your controls:

    var currCulture = kendo.culture();
    //currCulture.numberFormat.currency.symbol = '¥';
    //currCulture.numberFormat.currency.symbol = '€';
    //currCulture.numberFormat.currency.symbol = '$';
    currCulture.numberFormat.currency.symbol = '@Model.Currency.ToString()';
    
    $("#amount").kendoNumericTextBox({
        format: "c",
        decimals: 3,
        culture: currCulture
    });
    

    This would then print your models currency symbol.