asp.net-mvc – 如何启用创建,同时还禁用Kendo Grid的编辑
发布时间:2020-12-16 03:55:39 所属栏目:asp.Net 来源:网络整理
导读:是否可以仅启用在Kendo网格中插入新记录,但禁用编辑记录? 我能做的最好的是onDataBound删除JavaScript中的“编辑”按钮. 我尝试设置Editable(ed = ed.Enabled(false))但我在运行时遇到错误. @(Html.Kendo().Grid(Model) .Name("Grid" + guid) .HtmlAttribut
是否可以仅启用在Kendo网格中插入新记录,但禁用编辑记录?
我能做的最好的是onDataBound删除JavaScript中的“编辑”按钮. @(Html.Kendo().Grid(Model) .Name("Grid" + guid) .HtmlAttributes(new { style = "margin:20px" }) .Columns(columns => { columns.Bound(p => p.Id).Hidden(true); //a few more columns columns.Command(command => { command.Edit().Text(Resources.KendoEdit).UpdateText(Resources.KendoUpdateText).CancelText(Resources.KendoCancelText); command.Destroy().Text(Resources.KendoDestroy); }).Title(Resources.KendoCommands).Width(180); }) .ToolBar(toolbar => toolbar.Create().Text(Resources.KendoToolbarCreate)) .Editable(editable => editable //.Enabled(false) .Mode(GridEditMode.InLine) .DisplayDeleteConfirmation(false) ) .DataSource(dataSource => dataSource .Ajax() .ServerOperation(false) .Events(events => events.Sync("sync").Error("error")) .Model(mod => mod .Id(p => p.Id) ) .Model(mod => mod .Field(p => p.OldRoleId).Editable(false) ) .Read(read => read.Action("ChangeRole_Read","ChangeRole")) .Create(update => update.Action("ChangeRole_Create","ChangeRole")) .Update(update => update.Action("ChangeRole_Update","ChangeRole")) .Destroy(update => update.Action("ChangeRole_Destroy","ChangeRole")) ) .Sortable() .Filterable(filterable => filterable .Extra(true) .Operators(operators => operators .ForString(str => str.Clear() .StartsWith(Resources.KendoFilterStartsWith) .IsEqualTo(Resources.KendoFilterIsEqualTo) .IsNotEqualTo(Resources.KendoFilterIsNotEqualTo) .Contains(Resources.KendoFilterContains) .DoesNotContain(Resources.KendoFilterDoesNotContain) .EndsWith(Resources.KendoFilterEndsWith) ) ) .Messages(mess => mess .Info(Resources.KendoFilterMsgInfo) .And(Resources.KendoFilterMsgAnd) .Or(Resources.KendoFilterMsgOr) .Filter(Resources.KendoFilterMsgFilter) .Clear(Resources.KendoFilterMsgClear) ) ) .Scrollable() .Pageable(pg => pg .Refresh(true) .Messages(ms => ms .First(Resources.KendoPageableFirst) .Last(Resources.KendoPageableLast) .Next(Resources.KendoPageableNext) .Previous(Resources.KendoPageablePrevious) .Empty(Resources.KendoPageableEmpty) .Display(Resources.KendoPageableDisplay) ) ) .Events(ev => ev .Edit("edit") .Save("save") .DataBound("dataBound") ) ) 解决方法
唯一的方法是将“编辑”按钮的可见性设置为“无”:
<style> #yourgridid .k-grid-edit { display: none; } </style> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 通过Web Api接收,发送文件
- asp.net-mvc – 如何将MEF与ASP.NET MVC 4和ASP.NET Web AP
- asp.net – IIS7.5中x64进程的内存限制
- asp.net-mvc – 您对Telerik Extensions for MVC有何看法?
- asp.net-mvc – ASP.NET MVC – 执行控制器操作而不重定向
- asp.net – 奇数编号单元格未添加到Pdf
- asp.net-mvc – Firefox 4不呈现部分页面
- 什么是您最喜欢的ASP.NET添加工具/工具以提高生产力和代码
- 自定义数据注释ASP.NET MVC C#
- asp.net – 面向方面的开发/编程资源