根据Viewbag条件使Kendo ASP.NET MVC inCell可编辑
是否可以基于仅当您有某个 Viewbag 时才允许编辑的函数来制作 Kendo MVC 网格 .Editable() ?
我有一个名为 Viewbag.DisplayButton
的视图包。仅当您具有开发人员角色时,该 viewbag 才是“true”(因此非开发人员无法编辑任何内容)。我怎样才能使这个工作与 .Editable() 一起工作,以便您只能在有该 viewbag 的情况下编辑单元格?
目前,如果我设置 Editable(true),那么任何人(开发人员、客户,实际上任何人)都可以编辑单元格。如果我将其设置为可编辑(假),那么包括开发人员在内的任何人都无法编辑它。因此,我需要一个仅在您拥有特定视图包时才执行此操作的函数。
Is it possible to make a Kendo MVC grid .Editable() based on a function that allows editing ONLY if you have a certain Viewbag?
I have a viewbag that is Viewbag.DisplayButton
. That viewbag is only 'true' if you have a dev role (so non-devs cannot edit anything). How can I make this work with .Editable() so that you can only edit cells if you have that viewbag?
Currently if I set Editable(true) then anyone (devs, customers, literally anyone) can edit the cell. If I set it to Editable(false) then no one, including devs, can edit it. So I need a function that does it only if you have that specific viewbag.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为此,请使用 Razor 代码块。您可以将网格定义分配给变量,然后执行条件逻辑并添加其他配置(如果有)。最后调用Render方法。这是一个例子:
Use a Razor code block for this. You can assign the Grid definition to a variable, then execute the conditional logic and add the additional configurations, if any. Finally call the Render method. Here is an example: