国产精品久久久久久2021,日韩精品无码av中文无码版,亚洲精品久久久午夜麻豆,无码成人精品日本动漫纯h

010-68421378
當(dāng)前您所在的位置:首頁>新聞中心>新品發(fā)布

Kendo UI開發(fā)教程:Kendo DataSource概述

發(fā)布時間:2020/09/07 瀏覽量:3207
Kendo的數(shù)據(jù)源支持本地?cái)?shù)據(jù)源(JavaScript對象數(shù)組),或者遠(yuǎn)程數(shù)據(jù)源(XML, JSON, JSONP),支持CRUD操作(創(chuàng)建,讀取,更新和刪除操作),并支持排序,分頁,過濾,分組和集合等。

Kendo的數(shù)據(jù)源支持本地?cái)?shù)據(jù)源(JavaScript對象數(shù)組),或者遠(yuǎn)程數(shù)據(jù)源(XML, JSON, JSONP),支持CRUD操作(創(chuàng)建,讀取,更新和刪除操作),并支持排序,分頁,過濾,分組和集合等。

準(zhǔn)備開始

下面創(chuàng)建一個本地?cái)?shù)據(jù)源。

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});

創(chuàng)建一個遠(yuǎn)程數(shù)據(jù)源 (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”

}

});

綁定數(shù)據(jù)源到UI組件

Kendo UI組件很多都支持?jǐn)?shù)據(jù)綁定 ,UI組件綁定的數(shù)據(jù)源可以在配置UI組件時設(shè)置,或是多個UI組件共享同一個數(shù)據(jù)源。創(chuàng)建UI組件時設(shè)置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”

}

});

image001.jpg

使用共享的遠(yuǎn)程數(shù)據(jù)源:

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,模板的用法參見后面的文章。

下一篇:QuarkXPress Business : 可滿足企業(yè)、政府和教育機(jī)構(gòu)創(chuàng)建、發(fā)布等
上一篇:Cornerstone MFT:具有高可用性和故障切換功能,可消除停機(jī)時間

                               

 京ICP備09015132號-996 | 違法和不良信息舉報電話:4006561155

                                   © Copyright 2000-2026 北京哲想軟件有限公司版權(quán)所有 | 地址:北京市海淀區(qū)西三環(huán)北路50號豪柏大廈C2座11層1105室

                         北京哲想軟件集團(tuán)旗下網(wǎng)站:哲想軟件 | 哲想動畫

                            華滋生物