博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Kendo DataSource 概述
阅读量:4556 次
发布时间:2019-06-08

本文共 2432 字,大约阅读时间需要 8 分钟。

Kendo DataSource 概述

Kendo 的数据源支持本地数据源( JavaScript 对象数组),或者远程数据源(XML, JSON, JSONP),支持 CRUD 操作(创建,读取,更新和删除操作),并支持排序,分页,过滤,分组和集合等。

准备开始

下面创建一个本地数据源。

var movies = [ {      title: "Star Wars: A New Hope",      year: 1977   }, {     title: "Star Wars: The Empire Strikes Back",     year: 1980   }, {     title: "Star Wars: Return of the Jedi",     year: 1983   }];var localDataSource = new kendo.data.DataSource({data: movies});

创建一个远程数据源 (Twitter)

var dataSource = new kendo.data.DataSource({    transport: {        read: {            // the remote service url            url: "http://search.twitter.com/search.json",            // JSONP is required for cross-domain AJAX            dataType: "jsonp",            // additional parameters sent to the remote service            data: {                q: "html5"            }        }    },    // describe the result format    schema: {        // the data which the data source will be bound to is in the "results" field        data: "results"    }});

 

绑定数据源到 UI 组件

Kendo UI 组件很多都支持数据绑定 ,UI 组件绑定的数据源可以在配置 UI 组件时设置,或是多个 UI 组件共享同一个数据源。

创建UI组件时设置 DataSource 属性

$("#chart").kendoChart({    title: {        text: "Employee Sales"    },    dataSource: new kendo.data.DataSource({        data: [        {            employee: "Joe Smith",            sales: 2000        },        {            employee: "Jane Smith",            sales: 2250        },        {            employee: "Will Roberts",            sales: 1550        }]    }),    series: [{        type: "line",        field: "sales",        name: "Sales in Units"    }],    categoryAxis: {        field: "employee"    }});

 

使用共享的远程数据源

var sharableDataSource = new kendo.data.DataSource({    transport: {        read: {            url: "data-service.json",            dataType: "json"        }    }});// Bind two UI widgets to same DataSource$("#chart").kendoChart({    title: {        text: "Employee Sales"    },    dataSource: sharableDataSource,    series: [{        field: "sales",        name: "Sales in Units"    }],    categoryAxis: {        field: "employee"    }});$("#grid").kendoGrid({    dataSource: sharableDataSource,        columns: [        {            field: "employee",            title: "Employee"        },        {            field: "sales",            title: "Sales",            template: '#= kendo.toString(sales, "N0") #'    }]});

这个例子使用了模板 template ,模板的用法参见后面的文章。

转载于:https://www.cnblogs.com/miaosj/p/10361592.html

你可能感兴趣的文章
论学习汉语和学习编程的异同点
查看>>
linux img文件压缩及解压
查看>>
计算php脚本执行时间
查看>>
php静态和抽象
查看>>
Jolt:软件业的奥斯卡
查看>>
机器学习课程笔记 (1)
查看>>
基础数据类型 格式化输出
查看>>
第九周作业
查看>>
解析大型.NET ERP系统 单据编码功能实现
查看>>
互联网创业应该如何找到创意 - RethinkDB创始人Slava Akhmechet的几点建议
查看>>
互联网技术架构给我们的启示
查看>>
hbase redis mysql重要知识点总结
查看>>
取数字(dp优化)
查看>>
web app builder arcgis 自定义弹窗
查看>>
第六天冲刺
查看>>
Golang学习 - strconv 包
查看>>
ERROR util.Shell: Failed to locate the winutils binary in the hadoop binary path
查看>>
imx6 system boot
查看>>
[SDOI2017]硬币游戏
查看>>
Azure 网站、云服务和虚拟机比较
查看>>