【问题标题】:kendoui template DELETE and EDIT剑道 ui 模板删除和编辑
【发布时间】:2014-04-04 01:19:31
【问题描述】:

我想制作剑道模板:编辑、删除。

{
    field: "Action",
    template: '<a href="../edit/custom" ><span> EDIT</span></a> <a href="" class="deleteCustom"><span> DELETE</span>'
}

当我点击删除时,我需要一个确认弹出窗口,然后重定向到 url 以删除和刷新剑道,但是

$('.deleteCustom').onclick..

不起作用。我尝试在字段模板+命令中制作

{ field: "Activate", width: "100px",
                            template:"<span>edit<span>"
                            command: ["destroy"], title: " ", width: "160px",

                            },

但是模板消失了。为什么?命令是否重叠?我应该向左还是什么?

【问题讨论】:

    标签: jquery asp.net kendo-ui kendo-grid


    【解决方案1】:

    首先,您的第一个模板存在语义问题。你没有关闭最后一个&lt;a&gt; 标签:

    {
        field: "Action",
        template: '<a href="../edit/custom"><span>EDIT</span></a> <a href="" class="deleteCustom"><span>DELETE</span></a>'
    }
    

    那么你应该使用 jQuery 的on() 将点击绑定到你的删除/编辑链接:

    $('.deleteCustom').on('click', function() {
        // Here goes your confirmation...
    });
    

    要获取行信息,您应该使用:

    $('.deleteCustom').on('click', function() {
        var dataItem = grid.dataItem($(this).closest("tr"));
    
        if (window.confirm("Are your sure to delete " + dataItem.title + "?")) {
            location.href = "delete/" + dataItem.id;
        }
    });
    

    考虑到grid 是剑道网格实例。

    【讨论】:

    • 获得剑道网格是var grid = $("#Grid").data("kendoGrid");
    • 非常感谢yoyu。我会试试你的建议。
    • @studentsss 你对此有什么反馈吗?
    • 是的,最后我使用了jus模板。并为我工作。非常感谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-26
    • 1970-01-01
    • 1970-01-01
    • 2020-10-30
    • 1970-01-01
    相关资源
    最近更新 更多