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

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

Kendo UI使用教程:Kendo UI Grid中的動態(tài)數(shù)據(jù)(二)

發(fā)布時間:2021/05/23 瀏覽量:4528
Kendo UI使用教程:Kendo UI Grid中的動態(tài)數(shù)據(jù)(二)

圖片

 

本教程將為大家介紹如何逐步創(chuàng)建具有動態(tài)數(shù)據(jù)的Kendo UI grids。當(dāng)您在一遍又一遍輸入相同代碼時,可以知道有些是可以關(guān)閉的,您輸入的代碼正在獲取WET。創(chuàng)建具有動態(tài)數(shù)據(jù)的可編輯Kendo UI Grids是非常簡單的,Progress的技術(shù)支持工程師幫助很多客戶解決了有關(guān)動態(tài)數(shù)據(jù)的問題,并且提供了有關(guān)動態(tài)數(shù)據(jù)的建議,在本文中我們將會為大家一一解答。

 

 

3. 想要創(chuàng)建一個動態(tài)可編輯的Kendo UI Grid,我們首先需要在dataSource之前創(chuàng)建dataSource模式模型。在初始ajax請求的成功回調(diào)中,將示例dataItem傳遞給generateModel函數(shù)。該功能完成兩個非常重要的任務(wù):

 

該功能可以擴(kuò)展為包括其他模式模型設(shè)置,如驗證和默認(rèn)值?;蛘吣梢允占掌陬愋偷淖侄蚊Q,以便稍后在列設(shè)置中進(jìn)行格式化。

 

var dateFields = [];

 

function generateModel(sampleDataItem) {

var model = {};

var fields = {};

for (var property in sampleDataItem) {

if (property.indexOf("ID") !== -1) {

model["id"] = property;

}

 

var propType = typeof sampleDataItem[property];

if (propType === "number") {

fields[property] = {

type: "number"

};

if(model.id === property){

fields[property].editable = false;

}

} else if (propType === "boolean") {

fields[property] = {

type: "boolean"

};

} else if (propType === "string") {

var parsedDate = kendo.parseDate(sampleDataItem[property]);

if (parsedDate) {

fields[property] = {

type: "date"

};

dateFields[property] = true;

}

}

}

 

model.fields = fields;

 

return model;

}

 

4. 現(xiàn)在我們有了模式模型,可以創(chuàng)建Kendo UI數(shù)據(jù)源。該函數(shù)應(yīng)該接收基本URL和模型作為參數(shù)。由于服務(wù)遵循命名約定,因此可以使用CRUD操作輕松創(chuàng)建此動態(tài)數(shù)據(jù)源:

 

function generateDataSource(baseURL, model) {

var dataSource = {

transport: {

read: {

url: baseURL

},

create:{

url: baseURL + "Create"

},

update:{

url: baseURL + "Update"

},

destroy:{

url: baseURL + "Destroy"

},

parameterMap: function(options, operation) {

if (operation !== "read" && options.models) {

return {models: kendo.stringify(options.models)};

}

}

},

batch:true,

schema: {

model:model

},

pageSize: 10

};

 

return dataSource;

}

 
下一篇:萬興喵影:APP5.0全新上線 隨時隨地創(chuàng)作你的故事
上一篇:TechSmith Corporation:Camtasia和Snagit的語言選項

                               

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

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

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

                            華滋生物