Disable KendoGrid editing
来源:互联网 发布:javascript计算器代码 编辑:程序博客网 时间:2024/06/05 23:56
一、禁止整个KendoGrid编辑
将grid 转成kendo widgetInstance, 然后将属性editabled 设为 false
var $girdEles = $("#grid");//设置grid的不可修改 for (var i = 0; i < $girdEles.length; i++) { var $ele = $($girdEles[i]), widget = kendo.widgetInstance($ele); //将元素转换成kendo实例 if (widget) { widget.setOptions({ editable: false }); }}// 隱藏Toolbar//$("#grid .k-grid-toolbar").hide();//屏蔽Button組件 $("#grid .k-grid-toolbar .k-button").each(function () { $(this).addClass("k-state-disabled").attr("disabled", "disabled").removeAttr("onclick");});
二、禁止某列(Column)编辑
可以参考这里的做法 Disable editing in kendo grid 演示例子
html
<a href="#" id="button1" class="k-button">Disable Firstname</a><a href="#" id="button2" class="k-button">Enable Firstname</a><div id="grid"></div>js
var grid = $("#grid").kendoGrid({ dataSource: { data : createRandomData(50), pageSize: 10, schema : { model: { fields: { id : { type: 'number' }, FirstName: { type: 'string' }, LastName : { type: 'string' }, City : { type: 'string' }, Title : { type: 'string' }, BirthDate: { type: 'date' }, Age : { type: 'number' } } } } }, editable : "incell", pageable : { refresh : true, pageSizes: true }, columns : [ { field: "FirstName", width: 90, title: "First Name" } , { field: "LastName", width: 90, title: "Last Name" } , { width: 100, field: "City" } , { field: "Title" } , { field : "BirthDate", title : "Birth Date", template: '#= kendo.toString(BirthDate,"dd MMMM yyyy") #' } , { width: 50, field: "Age" } ]}).data("kendoGrid");$("#button1").on("click", function (e) { var data = grid.dataSource.at(0); console.log("data", data); data.fields["FirstName"].editable = false;});$("#button2").on("click", function (e) { var data = grid.dataSource.at(0); data.fields["FirstName"].editable = true;});效果图:
阅读全文
0 0
- Disable KendoGrid editing
- how to enable or disable registry editing in xp
- kendoGrid选中行信息
- KenDoGrid中使用checkbox
- kendoGrid 自定义列命令
- kendoGrid选中行信息
- kendoGrid jquery 数据列表加载
- uva_10115_Automatic Editing
- Automatic Editing
- Automatic Editing
- Editing string
- KenDoGrid中的控件为日期时间
- KenDoGrid中字段动态可编辑
- kendoGrid 选中上一行、下一行
- KendoGrid 动态显示/隐藏列(Column)
- Disable dhcp
- checkbox disable
- disable setunhandledexceptionfilter
- 【OpenGL ES】片段操作
- JAVA检查是否为乱码
- java synchronized详解
- java8新特性--optional
- jQuery设计思想
- Disable KendoGrid editing
- Spring框架单元测试
- 基于ruby+selenium的第三方广告检测
- Asp修改GridView中的数据变通方法
- VS.Net中程序集的Debug版本和Release版本的区别
- GIT学习
- ping和telnet
- openCV学习笔记 (六) : 改变图像的对比度和亮度
- brpop read error on connection