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

时间:2022-11-27 15:36:08

I'm use kendo ui grid popup and using code

我使用kendo ui grid popup并使用代码

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

I and use

我和使用

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

How to do this? In my kendo grid Custom button to call "tax_manage" in Views/Shared/EditorTemplates/tax_manage and show template inner popup with Javascript and when I click Custom Button I need to pass value to popup, such as a string (e.g.: this was called by Custom Button)

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

1 个解决方案

#1


0  

I guess you can send the parameter via the corresponding table row. To open the popup, you can use grid's editRow method:

我猜你可以通过相应的表格行发送参数。要打开弹出窗口,可以使用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. 
}

#1


0  

I guess you can send the parameter via the corresponding table row. To open the popup, you can use grid's editRow method:

我猜你可以通过相应的表格行发送参数。要打开弹出窗口,可以使用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. 
}