weixin_33701617 2015-06-11 13:51 采纳率: 0%
浏览 106

如何删除Kendo Grid中跟自定义删除按钮相关的行?

<%: Html.Kendo().Grid<Model>()
        .Name("Grid")
        .BindTo((IEnumerable<Model>)ViewBag.List)
        .Columns(columns =>
        {
            columns.Bound(p => p.PK).Title("pk");
            columns.Bound(p => p.NAME).Title("Name");


            columns.Command(command => command.Custom("Delete").Click("Delete")).Width(100);

        })

        %>     


<div id="modalWindow">
            <h2>Delete?</h2>
            <button id="yes" class="k-button">Yes</button>
            <button id="no" class="k-button">No</button>
        </div>


        <script>             

            var wnd;
            $(document).ready(function () {
                wnd = $("#modalWindow").kendoWindow({
                    title: "Delete confirmation",
                    modal: true,
                    visible: false,
                    resizable: false,
                    width: 300
                }).data("kendoWindow");

            });


            function Delete(e) {
                e.preventDefault();

                var grid = this;
                var row = $(e.currentTarget).closest("tr");
                wnd.center().open();



                $("#yes").unbind('click').click(function () {       

                    $.ajax({                          

                        type: 'POST',
                        url: '/Home/Delete',
                        data: ???
                        contentType: 'application/json; charset=utf-8',


                        success: function (result) {

                        },
                        error: function (err, result) {
                        alert("Error in delete" + err.responseText);
                        }

                    });                   

                    grid.removeRow(row);
                    wnd.close();
                });


                $("#no").unbind('click').click(function () {
                    wnd.close();
                });
            }      
        </script>

你好,我想删除Kendo Grid中跟自定义删除按钮相关的行。脚本运行良好,但是数据存在着问题:我不知道如何获取该行以及如何删除它?单击自定义按钮后如何获取?

谢谢!

  • 写回答

2条回答 默认 最新

  • weixin_33739646 2015-06-11 13:57
    关注

    Do you know the underlying dataItem's ID property ? You can grab the dataItem from the grid's datasource once you have the row. So after the var row = $(e.currentTarget).closest('tr'); you can add a var dataItem = grid.dataItem(row); And then you should be able to get the id property of the dataItem dataItem.id(or some such);

    评论

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services