Kendo UI目前最新提供Kendo UI for jQuery、Kendo UI for Angular、Kendo UI Support for React和Kendo UI Support for Vue四個控件。Kendo UI for jQuery是創(chuàng)建現(xiàn)代Web應(yīng)用程序的完整UI庫。
編輯是Kendo UI網(wǎng)格的基本功能,可讓您操縱其數(shù)據(jù)的顯示方式。
Kendo UI Grid提供以下編輯模式:

批量編輯
網(wǎng)格使您能夠進(jìn)行和保存批量更新。要在網(wǎng)格中啟用批處理編輯操作,請將數(shù)據(jù)源的批處理選項設(shè)置為true。
內(nèi)聯(lián)編輯
當(dāng)用戶單擊一行時,網(wǎng)格提供用于內(nèi)聯(lián)編輯其數(shù)據(jù)的選項。要啟用內(nèi)聯(lián)編輯操作,請將Grid的editable選項設(shè)置為inline。
彈出式編輯
網(wǎng)格提供用于在彈出窗口中編輯其數(shù)據(jù)的選項。要啟用彈出窗口編輯操作,請將Grid的editable選項設(shè)置為popup。
!DOCTYPE html>
自定義編輯
網(wǎng)格使您可以實現(xiàn)自定義列編輯器,并指定在用戶編輯數(shù)據(jù)時適用的驗證規(guī)則。
實施自定義編輯器
要在網(wǎng)格中實現(xiàn)自定義編輯器,請指定相應(yīng)列的編輯器字段。該字段的值將指向JavaScript函數(shù),該函數(shù)將實例化對應(yīng)列單元格的列編輯器。
$(document).ready(function () {
var dataSource = new kendo.data.DataSource({
pageSize: 20,
data: products,
autoSync: true,
schema: {
model: {
id: "ProductID",
fields: {
ProductID: { editable: false, nullable: true },
ProductName: { validation: { required: true } },
Category: { defaultValue: { CategoryID: 1, CategoryName: "Beverages"}},
UnitPrice: { type: "number", validation: { required: true, min: 1} }
}
}
}
});
$("#grid").kendoGrid({
dataSource: dataSource,
pageable: true,
height: 550,
toolbar: ["create"],
columns: [
{ field:"ProductName",title:"Product Name" },
{ field: "Category", title: "Category", width:"180px", editor: categoryDropDownEditor, template:"#=Category.CategoryName#" },
{ field: "UnitPrice", title:"Unit Price", format:"{0:c}", width: "130px" },
{ command: "destroy", title: " ", width: "150px"}],
editable: true
});
});
function categoryDropDownEditor(container,options) {
$(‘’)
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataTextField: "CategoryName",
dataValueField: "CategoryID",
dataSource: {
type: "odata",
transport: {
read: "https://demos.telerik.com/kendo-ui/service/Northwind.svc/Categories"
}
}
});
}
設(shè)置驗證規(guī)則
要為編輯操作定義驗證規(guī)則,請在數(shù)據(jù)源的架構(gòu)中配置驗證選項。
京ICP備09015132號-996 | 違法和不良信息舉報電話:4006561155
© Copyright 2000-2026 北京哲想軟件有限公司版權(quán)所有 | 地址:北京市海淀區(qū)西三環(huán)北路50號豪柏大廈C2座11層1105室
北京哲想軟件集團(tuán)旗下網(wǎng)站:哲想軟件 | 哲想動畫