简体   繁体   中英

MVC- Kendo DateTimePicker Culture Doesn't work with KnockoutJS?

i am trying to change Kendo DateTimePicker's language.Added culture files to change DatePicker on Page load.It works great if i dont apply knockoutjs binding.But i must use knockout's data-bind to make it works.

    @(Html.Kendo().DateTimePicker()
     .Name("dtStart")
     .Culture(@CultureHelper.GetCultureShort())
     .Format("dd/MM/yyyy HH:mm")
     .TimeFormat("HH:mm")
     .ParseFormats(new string[] { "MM/dd/yyyy" })
     .Events(e => e.Change("dtStart_onChange"))
     //It stops changing to culture if i use "data-bind" here 
    //.HtmlAttributes(new { data_bind = "kendoDateTimePicker: selectedStartDate" })
               )

Tried this , but script works before datepicker created;

Js:

         var lang = '@CultureHelper.GetCultureShort()';
        $("#dtStart").kendoDatePicker({
        culture: lang,
            //....
        });

You use that js to initialize the DateTimePicker. Since you're invoking it in Razor you can just call it up in your js and 'setOptions' with ::

$("#dtStart").data("kendoDatePicker").setOptions({
    culture: lang
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM