Search code examples
javascriptasp.net-mvckendo-uikendo-asp.net-mvckendo-scheduler

Kendo UI Scheduler - Changing date format, ASP.NET MVC version


I have the same problem like this: change date format, using javascript

but I'm using the ASP.NET MVC version. There is no 'Databound' element for 'Html.Kendo().Scheduler<...>()'.

So where can I put that 'scheduler_dataBound' function? Or is there another different solution from the javascript version?


Solution

  • There is a data binding event on the MVC wrapper one: You can also do e.Navigate("scheduler_navigate"); and e.DataBound("scheduler_dataBound");

     .Events(e =>
                        {                      
                            e.DataBinding("scheduler_dataBinding");                      
                        })
    
    
    
    <script>
    
    function scheduler_dataBound(e) {
        if (this.viewName() != "month") {
            var test = $(".k-lg-date-format").html().split('-'); 
            var _str = kendo.toString(kendo.parseDate(test[0].trim()), 'ddd MM/dd');
            if (test.length == 2) {
                _str += " - " + kendo.toString(kendo.parseDate(test[1].trim()), 'ddd MM/dd');
            } 
            $(".k-lg-date-format").html(_str);
            $(".k-sm-date-format").html(_str); 
        }
    }
    </script>
    

    Here's a link to the rest of the events http://demos.telerik.com/aspnet-mvc/scheduler/events