Kendo UI Grid MVC - 为什么在设置单元格模式时,每行末尾会出现一个编辑按钮?

时间:2017-02-18 14:42:06

标签: kendo-ui kendo-grid

我的代码如下:

@(Html.Kendo().Grid<JeffreysOnline.Entities.Customer>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.LastName).Width(150);
        columns.Bound(p => p.FirstName).Width(125);
        columns.Bound(p => p.MiddleInitial).Width(75);
        columns.Bound(p => p.Phone).Width(125);
        columns.Bound(p => p.Address).Width(150);
        columns.Bound(p => p.City).Width(100);
        columns.Bound(p => p.State).Width(50);
        columns.Bound(p => p.Zip).Width(125);
        columns.Bound(p => p.TaxName).Width(125);
        columns.Bound(p => p.TaxId).Width(125);
        columns.Bound(p => p.BadChecks).Width(125);
        columns.Bound(p => p.OtherRisk).Width(125);
        columns.Bound(p => p.Interests).Width(125);
        columns.Bound(p => p.BirthDate).Width(125);
        columns.Bound(p => p.BouncedCheck).Width(125);
        columns.Bound(p => p.PCNumber).Width(125);
        columns.Bound(p => p.Comments).Width(125);
        columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
    })
    .ToolBar(toolbar =>
    {
        toolbar.Create();
        toolbar.Save();
        toolbar.Excel();
    })
    .Editable(editable => editable.Mode(GridEditMode.InCell)) // In-cell editing instead of the whole row
    .Pageable()
    .Navigatable() // This allows the user to tab between columns in the grid.
    .Sortable()
    .Scrollable()
    .Groupable()
    .Excel(excel => excel
        .FileName("Customers.xlsx")
        .Filterable(true)
        .AllPages(false)
        .ProxyURL(Url.Action("ExcelExport", "Customer"))
     )
    .HtmlAttributes(new { style = "height:700px;" })
    .DataSource(dataSource => dataSource
        .Ajax()
        .Batch(true)                                            // We want to perform batch operations
        .PageSize(500)                                          // Set the page size
        .Events(events => events.Error("error_handler"))        // Define a function that gets called on an error
        .Model(model => model.Id(p => p.RowId))                 // Define the PK
        .Create(update => update.Action("Create", "Customer"))  // The Create method in the controller
        .Read(read => read.Action("Read", "Customer"))          // The Read method in the controller
        .Update(update => update.Action("Update", "Customer"))  // The Update method in the controller
        .Destroy(update => update.Action("Delete", "Customer")) // The Delete method in the controller
    )

当网格在网页上呈现时,最后一列会显示一个编辑按钮:

enter image description here

为什么在设置单元格内编辑模式时会出现此编辑按钮?

1 个答案:

答案 0 :(得分:1)

您的意思是Edit按钮吗?你在这里的代码中添加它:

columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);

删除command.Edit();语句,按钮应该消失。