简体   繁体   English

Kendo MVC Grid在运行时设置/更改编辑模板

[英]Kendo MVC Grid set / change edit template at runtime

I have a Kendo MVC Grid 我有一个Kendo MVC网格

 @(Html.Kendo().Grid<...>() .... .Editable(ed => ed.Mode(GridEditMode.PopUp).TemplateName("Editor_Name_A").Window(w => { w.Title(""); w.Width(700); }).DisplayDeleteConfirmation(false)) .DataSource(dataSource => dataSource ... 

I have another two simple buttons: button_A and button_B somewhere else in the document, and what I am trying to do is, when user click button_A , the grid will use template Editor_Name_A , while if user click button_B , the grid will use template Editor_Name_B 我还有另外两个简单的按钮: button_Abutton_B在文档中的其他位置,我想做的是,当用户单击button_A ,网格将使用模板Editor_Name_A ,而如果用户单击button_B ,则网格将使用模板Editor_Name_B

It is like dynamically setting / changing the grid edit template conditionally, is there any way to achieve it? 就像有条件地动态设置/更改网格编辑模板一样,有什么方法可以实现吗?

You will probably have to do it with some javascript in the page itself and try these approaches: 您可能必须在页面本身中使用一些javascript,然后尝试以下方法:

  1. change the template name with javascript upon clicking the buttons and reload the grid. 单击按钮并使用javascript更改模板名称,然后重新加载网格。
  2. Set a global parameter, or hidden field value according to buttons click and use one template with condition inside it, that renders different html by that parameter. 根据单击的按钮设置全局参数或隐藏字段值,并使用一个内部带有条件的模板,该模板通过该参数呈现不同的html。 check this 检查这个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM