kendo-ui - Kendo Grid - 单击模板化列时的编辑模式

标签 kendo-ui kendo-grid

我正在使用编辑弹出窗口的模板。我试图强制网格进入编辑模式,并在单击其中一列中的链接时显示编辑模板弹出窗口。

我尝试使用命令,但无法将超链接的文本数据绑定(bind)到模型中声明的字段,在本例中为“CourseType”。 命令 列中是否支持数据绑定(bind)?

columns: [
     { 
        command: [
          { 
            id: "edit", 
            title: "School Item",    
            template: '<a href="\\#">#=CourseType#</a>',  
            width: 120
          }
       ]
     }
]

如果命令列不支持数据绑定(bind),那么如何在单击模板化字段时将网格置于编辑模式?

columns: [
  { 
    field: "CourseType", 
    title: "School Item",  
    template: '<a href="\\#">#=CourseType#</a>'
  }
]

最佳答案

我不确定为什么要将单元格定义为 HTML anchor,但是在单击 anchor 时使其进入弹出编辑模式没有问题。

1) 在您的模板中添加一个,使我们能够找到这些单元格。像这样的东西:

columns: [
    {
        field: "CourseType",
        title: "School Item",
        template: '<a href="\\#" class="ob-edit-popup">#=CourseType#</a>'
    }
]

我在模板中包含 class="ob-edit-popup"

2) 在您的网格定义中添加选项 editable: "popup"

3) 初始化后添加如下JavaScript代码。

$(".ob-edit-popup", grid.tbody).on("click", function (e) {
    var row = $(this).closest("tr");
    grid.editRow(row);
})

grid 的结果是:

var grid = $("#grid").kendoGrid({...}).data("kendoGrid");

关于kendo-ui - Kendo Grid - 单击模板化列时的编辑模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14837995/

相关文章:

css - 如何在 Angular kendomultiselect 中的选定图 block 之一上添加 css

javascript - KendoUI 列模板中的条件未按预期工作

javascript - 剑道用户界面 : Dynamically change dataSource of grid on button click event

javascript - 如何在剑道网格行悬停上给出边框

javascript - kendo UI-基于列值的kendo ui网格中的条件列

javascript - 如何使用 KendoDetailInit 函数从另一个网格的不同行获取不同的网格作为子级

kendo-grid - Kendo UI Grid 本地数据源列默认排序

kendo-ui - 网格导出表数据在 IE 10 和 mozilla 中不起作用

asp.net-mvc - 包含在 ClientDetailTemplate 中时,客户端模板未定义错误

twitter-bootstrap - 剑道网格页脚/寻呼机在 Bootstrap 选项卡内损坏