摘要:

  前面介绍了一款非常不错的前端框架kendo-ui,如果你想阅读,请点这里。通过使用它一段时间,感觉是非常好用。下面就介绍一下如何使用它和开发自己的组件

引入:

  只需要引进下面三个文件即可

 kendo.common.min.css  通用样式
 kendo.default.min.css 皮肤
 kendo.all.min.js js文件
 <!DOCTYPE html>
<html>
<head>
<title>Welcome to Kendo UI!</title>
<link href="styles/kendo.common.min.css" rel="stylesheet" />
<link href="styles/kendo.default.min.css" rel="stylesheet" />
<script src="js/jquery.min.js"></script>
<script src="js/kendo.all.min.js"></script>
</head>
<body> </body>
</html>

开发自己的组件:

第一步:继承基本组件

 (function($) {
// shorten references to variables. this is better for uglification
var kendo = window.kendo,
ui = kendo.ui,
Widget = ui.Widget var MyWidget = Widget.extend({
// initialization code goes here
}); })(jQuery);

注意:

1、为了保护全局的命名空间,开发组件是在单独的函数中执行,确保$是jQuery

2、组件是继承基本组件的,所以组件名首字母大写

第二步:添加一个初始化的方法

 var MyWidget = Widget.extend({

     init: function(element, options) {

         // base call to initialize widget
Widget.fn.init.call(this, element, options); }
});

当这个组件初始化时,这个方法会被框架调用。两个参数,第一个是宿主元素,第二个是配置参数

第三步:添加配置参数

 var MyWidget = Widget.extend({

     init: function(element, options) {

         // base call to initialize widget
Widget.fn.init.call(this, element, options);
}, options: {
// the name is what it will appear as off the kendo namespace(i.e. kendo.ui.MyWidget).
// The jQuery plugin would be jQuery.fn.kendoMyWidget.
name: "MyWidget",
// other options go here
...
} });

第四步:暴露组件

 kendo.ui.plugin(MyWidget);

下面是一个详细的列表组件:

 (function() {
var kendo = window.kendo,
ui = kendo.ui,
Widget = ui.Widget, CHANGE = "change"; var Repeater = Widget.extend({
init: function(element, options) {
var that = this; kendo.ui.Widget.fn.init.call(that, element, options);
that.template = kendo.template(that.options.template || "<p><strong>#= data #</strong></p>"); that._dataSource();
},
options: {
name: "Repeater",
autoBind: true,
template: ""
},
refresh: function() {
var that = this,
view = that.dataSource.view(),
html = kendo.render(that.template, view); that.element.html(html);
},
_dataSource: function() {
var that = this;
// returns the datasource OR creates one if using array or configuration object that.dataSource = kendo.data.DataSource.create(that.options.dataSource); // bind to the change event to refresh the widget
that.dataSource.bind(CHANGE, function() {
that.refresh();
}); if (that.options.autoBind) {
that.dataSource.fetch();
}
}
}); kendo.ui.plugin(Repeater); })(jQuery);

使用:

 <div id="repeater"></div>
<script>
$("#repeater").kendoRepeater({
dataSource: [ "item1", "item2", "item3" ]
});
</script>

效果图:

kendo-ui的使用和开发自己的组件的更多相关文章

  1. 准备Kendo UI 开发环境

    准备 首先你需要从 Telerik 网站下载试用版开发包,注意需要注册后才能下载. 下载后直接解压后包含下面几个文件和目录: ./examples – 示例. /js – minified 化后的 J ...

  2. 关于Kendo UI 开发教程

    Kendo UI 开发教程 jQuery UI 是一套 JavaScript 函式库,提供抽象化.可自订主题的 GUI 控制项与动画效果.基于 jQuery JavaScript 函式库,可用来建构互 ...

  3. Python开发篇——基于React-Dropzone开发上传组件

    这次我要讲述的是在React-Flask框架上开发上传组件的技巧.我目前主要以React开发前端,在这个过程中认识到了许多有趣的前端UI框架--React-Bootstrap.Ant Design.M ...

  4. [置顶] Kendo UI开发教程: Kendo UI 示例及总结

    前面基本介绍完Kendo UI开发的基本概念和开发步骤,Kendo UI的示例网站为http://demos.kendoui.com/ ,包含了三个部分 Web DemoMobile DemoData ...

  5. Kendo UI开发教程(27): 移动应用开发简介

    Kendo UI 支持开发Web应用,前面介绍的SPA,也支持开发移动应用,至于使用 HTML5 + JavaScript + CSS开发移动是不是一个好的选择不在本文的讨论之中.Kendo UI M ...

  6. Kendo UI开发教程(16): Kendo MVVM 数据绑定(五) Events

    本篇和Kendo UI开发教程(14): Kendo MVVM 数据绑定(三) Click类似,为事件绑定的一般形式.Events绑定支持将ViewModel的方法绑定到DOM元素的事件处理(如鼠标事 ...

  7. Kendo UI开发教程(9): Kendo UI Validator 概述

    Kendo UI Validator 支持了客户端校验的便捷方法,它基于HTML 5 的表单校验功能,支持很多内置的校验规则,同时也提供了自定义规则的便捷方法. 完整的Kendo UI 的Valida ...

  8. 【Kendo UI系列开发使用笔记】01-简单介绍

    ps:接触telerik出品的kendo ui系列已经快有一年了,使用过程中也在不断踩坑填坑.这套UI用起来还是非常爽的,尤其asp.net mvc版的配合lambda表达式来配置参数非常流畅.这次对 ...

  9. Kendo UI 移动应用开发简介

    Kendo UI 移动应用开发简介 Kendo UI 支持开发 Web 应用,前面介绍的 SPA,也支持开发移动应用,至于使用 HTML5 + JavaScript + CSS 开发移动是不是一个好的 ...

  10. Web UI开发推荐!Kendo UI for jQuery自定义小部件——使用MVVM

    Kendo UI for jQuery最新试用版下载 Kendo UI目前最新提供Kendo UI for jQuery.Kendo UI for Angular.Kendo UI Support f ...

随机推荐

  1. sql排它锁

    1.为什么需要排它锁 事务中,有时我们在操作一条数据时,是不能让其他事务同时去操作的. 如某商品库存数量为1,如果有多个事务对该库存进行减一操作,那么库存可能出现负数. 所以,在某个事务操作时,需要把 ...

  2. PHP源代码生成 main/config.w32.h

    PHP源代码生成 main/config.w32.h 1.下载php源代码包php-5.4.0.tar.gz,解压到D:\php-5.4.0 2.下载2个必要的包http://xiazai.jb51. ...

  3. vue实现复制粘贴的两种形式

    方式一: 1.安装clipboard:npm install clipboard 2.src/utils/clipboard.js import Vue from 'vue' import Clipb ...

  4. LeetCode: Maximal Rectangle 解题报告

    Maximal RectangleGiven a 2D binary matrix filled with 0's and 1's, find the largest rectangle contai ...

  5. 解决CentOS中/var目录满的问题

    最近服务器的/var目录总是报警说磁盘满了,查看以后发现主要是/var/log/maillog和/var/spool/mail/root和/var/spool/mqueue目录.从搜索的结果看到应该是 ...

  6. jquery 时间戳和日期时间转化

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...

  7. 一款基于jquery超炫的图片切换特效

    今天为给大家介绍一款基于jquery超炫的图片切换特效.由百叶窗飞入显示图片.图片消息的时候也是百叶窗渐行渐远.用于图片展示,效果还是非常好,我们一起看下效果图: 在线预览   源码下载 来看下实现的 ...

  8. dubbo2.5.3注解版

    1.环境      在机器192.168.0.4机器上安装了zookeeper,用于dubbo的服务注册,安装教程在另外一篇博客 http://www.cnblogs.com/520playboy/p ...

  9. iio adc转换应用编写

    #include <stdio.h>        #include <stdlib.h>         #include <fcntl.h>         # ...

  10. SpringMVC 利用AbstractRoutingDataSource实现动态数据源切换

    SpringMVC 利用AbstractRoutingDataSource实现动态数据源切换 本文转载至:http://exceptioneye.iteye.com/blog/1698064 Spri ...