如何使用自定义按钮调用编辑器模板并将值传递给弹出窗口

How to use custom button call Editor template and passing value to popup

我正在使用 kendo ui 网格弹出窗口并使用代码

.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("tax_manage")

我和使用

columns.Command(command => command.Custom("ViewData").Text("ViewData")).Width(60).Title("ViewData"); 

如何做到这一点? 在我的 kendo 网格自定义按钮中调用 Views/Shared/EditorTemplates/tax_manage 中的 "tax_manage" 并使用 Javascript 显示模板内部弹出窗口,当我单击自定义按钮时,我需要将值传递给弹出窗口,例如字符串(例如:这是由自定义按钮调用的)

我想您可以通过相应的 table 行发送参数。要打开弹窗,可以使用grid的editRow方法:

columns.Command(command => command.Custom("ViewData").Text("ViewData").Click("cmdClick"))
...
.Events(events => events.Edit("gridEdit"))
function cmdClick(e) {
    var tr = $(e.target).closest("tr"); // get the corresponding table row
    var grid = $("#grid").data("kendoGrid");
    var dataItem = grid.dataItem(tr); // You may want to use the corresponding data item ...
    tr.data("message") = "This was called by Custom Button";
    grid.editRow(tr);
}
function gridEdit(e) {
    var dataItem = e.model;
    var tr = $("#grid").data("kendoGrid").tbody.find("tr[data-uid='" + dataItem.uid + "']");
    var message = tr.data("message");
    ... // do something with the message. 
}