首页 > 代码库 > Kendo UI 使用札记
Kendo UI 使用札记
AutoComplete
// html <input class="chooseCountry" type="text"/> // js $(document).ready(function () { var data =http://www.mamicode.com/ [ "中国", "中国台湾", "中国断臂山", "日本", "台湾" ]; //create AutoComplete UI component $(".chooseCountry").kendoAutoComplete({ dataSource: data, filter: "startswith", placeholder: "选择你的国家,蠢货!", separator: ", " }); });
Button
// html <p class="button-primary">primary Button</p> <p class="button-passed">disabled Button</p> // js $(".button-primary").kendoButton({ enable : true, icon : "wolf" // create span inner obj, and span.class = kin-icon, k-i-"this.value"; }); $(".button-passed").kendoButton({ enable : false, spriteCssClass : "k-icon k-i-refresh" // create span inner obj, and span.class = this.value; });
Calendar
// html <div class="calendar"> <!-- kendo will create calendar elements here --> </div> // js $(".calendar").kendoCalendar();
ColorPicker
// HTML <!-- color picker --> <div class="color_picker_wrap" style="width:400px;"> <div class="color_view" style="height:60px; padding: 10px; background: #000"> <h3 style="color: #fff;">COLOR VIEW</h3> </div> <div class="color_choose"></div> <br/> <input class="color_customer_choose"/> </div> // JS function preview(e) { $(".color_view").css("background-color", e.value); } $(".color_choose").kendoColorPalette({ columns: 4, tileSize: { width: 35, height: 19 }, palette: [ "#e1dca5", "#d0c974", "#a29a36", "#514d1b", "#c6d9f0", "#8db3e2", "#548dd4", "#17365d", "#e1dca5", "#d0c974", "#a29a36", "#514d1b", "#c6d9f0", "#8db3e2", "#548dd4", "#17365d" ], change: preview }); $(".color_customer_choose").kendoColorPicker({ value: "#fff", buttons: false, select: preview
});
ComboBox
// html <!-- combobox --> <div class="combobox-wrap" style="background:#ddd; padding: 10px;"> <h3>choose drink</h3> <input id="choose_drink" type="text" placeholder="Select drink..."/> <h3>size</h3> <!-- kendo will create elements replace select, select will hide --> <select id="size" name="" placeholder="Select size..."> <option value="">迷你杯</option> <option value="">小杯</option> <option value="">中杯</option> <option value="">大杯</option> <option value="">特大杯</option> </select> <button id="order-submit">submit order</button> </div> // JS // create ComboBox from input HTML element; $("#choose_drink").kendoComboBox({ dataTextField : "text", dataValueField : "value", dataSource : [ { text: "coffee", value : "1"}, { text: "banana juice", value : "2"}, { text: "apple juice", value : "3"}, { text: "ice juice", value : "4"} ], filter : "contains", suggest : true, index : 3 }); // create ComboBox from select HTML element $("#size").kendoComboBox(); var fabric = $("#choose_drink").data("kendoComboBox"); var select = $("#size").data("kendoComboBox"); $("#order-submit").click(function() { alert(‘Thank you! Your Choice is:\n\nDrink ID: ‘ + fabric.value() + ‘ and Size: ‘ + select.value()); });
DatePicker
<div class="date_picker_wrap"> <input id="datePicker" type="text"/> </div> // JS // create DateTimePicker from input HTML element $("#dateTimePicker").kendoDatePicker();
DateTimePicker
<div class="date_time_picker_wrap"> <input id="dateTimePicker" type="text"/> </div> // JS // create DateTimePicker from input HTML element $("#dateTimePicker").kendoDateTimePicker();
DropDownList
// HTML <!-- drop down list --> <div class="drop_down_list_wrap"> <h3>cap Color</h3> <input id="capColor"/> <h3>cap Size</h3> <select id="capSize"> <option>S - 6 3/4"</option> <option>M - 7 1/4"</option> <option>L - 7 1/8"</option> <option>XL - 7 5/8"</option> </select> <button class="capOrder_submit">submit order</button> </div> // JS function dropDownList (){ var capColorData =http://www.mamicode.com/ [ { text: "Black", value: "1"}, { text: "Orange", value: "2"}, { text: "Blue", value: "3"} ]; // create DropDownList from input HTML element; $("#capColor").kendoDropDownList({ dataTextField: "text", dataValueField: "value", dataSource: capColorData, index: 0, change: onChange }); // create DropDownList frome select HTML element; $("#capSize").kendoDropDownList(); var color = $("#capColor").data("kendoDropDownList"); color.select(0); var size = $("#capSize").data("kendoDropDownList"); // it‘s a function when <select></select> on change; function onChange(){ var value = http://www.mamicode.com/$("#capColor").val(); // get current select.selected.value; value =http://www.mamicode.com/= 1 || 2 || 3 // three toggleClass default is not execute, when <select/> onchange,get that value then into this.toggleClass execute boolean operation; $("#cap").toggleClass("black-cap", value =http://www.mamicode.com/= 1) .toggleClass("orange-cap", value =http://www.mamicode.com/= 2) .toggleClass("blue-cap", value =http://www.mamicode.com/= 3); } $(".capOrder_submit").click(function (){ alert("Thank you! Your choice is:\n\nColor ID: " + color.value() + " and Size: " + size.value()); }); } dropDownList();
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。