简体   繁体   中英

Kendo MVC Grid set / change edit template at runtime

I have a Kendo MVC Grid

 @(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

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:

  1. change the template name with javascript upon clicking the buttons and reload the grid.
  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. check this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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