首页 文章

将按钮放置在列中的所有Kendo Grid行中

提问于
浏览 294 次
0

需要您的输入才能实现此目的:

我有一个Kendo Grid,我可以使用内联编辑模式添加新行和编辑行 . 这个Kendo Grid有不同的列 . 在此,将使用Button呈现一列(将Button放在列的所有行中) .

当我读取数据时,我能够看到列上的按钮 . Kendo Grid with Button Column

但是,当我尝试添加行或编辑行时,该按钮将替换为普通文本框 . Button not visible when Grid is in Edit Mode

如何在添加新行或使用模板编辑现有行时显示Button .

我会等你的意见 .

谢谢 .

1 回答

  • 2

    找到这段代码片段here . 只是想分享这些信息,这也可以帮助其他人:

    var ds = [
    { ID : 1, RowID : 1, BillNumber : "bn1" },
    { ID : 2, RowID : 2, BillNumber : "bn2" },
    { ID : 3, RowID : 3, BillNumber : "bn3" }];
    
    var grid = $("#grid").kendoGrid({
    dataSource: ds,
    columns: [
        { field: "ID", Title: "ID", filterable: false, sortable: false, hidden: false },
        { field: "BillNumber", Title: "BillNumber", filterable: false, sortable: false, hidden:true },
        {
            title: "Preview ", 
            template: '<input type="button" class="k-button info" name="info" value="Info" />',                       
            headerTemplate: '<label>  <input type="checkbox" id="checkAll"/>Print All</label>', 
            filterable: false, 
            sortable: false, 
            width: 100                     
        }
    ]}).data("kendoGrid");
    
    $(".info").on("click", function() {
        var row = $(this).closest("tr");
        var item = grid.dataItem(row);
        alert("Selected item is:" + JSON.stringify(item));
    });
    

相关问题