HTML5 Web app開發工具Kendo UI Web教程:如何配置Kendo UI Calendar

Kendo UI Web包含數百個創建HTML5 web app的必備元素,包括UI組件、數據源、驗證、一個MVVM框架、主題、模板等。本文來看看如何配置Kendo UI Calendar。

1、創建新的操作方法來顯示視圖:

public ActionResult Index()
{
    return View();
}

2、添加日曆

WebForms

<%: Html.Kendo().Calendar()
    .Name("calendar") //The name of the calendar is mandatory. It specifies the "id" attribute of the widget.
    .Min(new DateTime(2010, 1, 1, 10, 0, 0)) //Set min time of the calendar
    .Max(new DateTime(2010, 1, 1, 20, 0, 0)) //Set min date of the calendar
    .Value(DateTime.Now) //Set the value of the calendar
%>

Razor

@(Html.Kendo().Calendar()
    .Name("calendar") //The name of the calendar is mandatory. It specifies the "id" attribute of the widget.
    .Min(new DateTime(2010, 1, 1, 10, 0, 0)) //Set min time of the calendar
    .Max(new DateTime(2010, 1, 1, 20, 0, 0)) //Set min date of the calendar
    .Value(DateTime.Now) //Set the value of the calendar
)

訪問Existing Calendar

通過jQuery.data()引用一個現有日曆實例,一旦建議了引用,就可以使用API來控制它的行爲。

訪問現有日曆實例

//Put this after your Kendo Calendar for ASP.NET MVC declaration
<script>
$(function() {
// Notice that the Name() of the calendar is used to get its client-side instance
var calendar = $("#calendar").data("kendoCalendar");
});
</script>

處理Kendo UI Calendar事件

通過Kendo UI Calendar可以訂閱所有的事件。

WebForms -由處理程序名稱訂閱

<%: Html.Kendo().Calendar()
    .Name("calendar")
    .Events(e => e
        .Change("calendar_change")
        .Navigate("calendar_navigate")
    )
%>
<script>
function calendar_navigate() {
    //Handle the navigate event
}
       
function calendar_change() {
    //Handle the change event
}
</script>

Razor -由處理程序名稱訂閱

@(Html.Kendo().Calendar()
  .Name("calendar")
  .Events(e => e
        .Change("calendar_change")
        .Navigate("calendar_navigate")
  )
)
<script>
function calendar_navigate() {
    //Handle the navigate event
}
     
function calendar_change() {
    //Handle the change event
}
</script>

Razor -通過模板委託訂閱

@(Html.Kendo().Calendar()
  .Name("calendar")
  .Events(e => e
      .Change(@<text>
        function() {
            //Handle the change event inline
        }
      </text>)
      .Navigate(@<text>
        function() {
            //Handle the navigate event inline
        }
        </text>)
  )

點擊下載Kendo UI Web

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章