javascript - 剑道 UI 网格 : how to make cell read only on condition

标签 javascript jquery angularjs kendo-ui kendo-grid

在 Kendo UI 网格(使用 Angularjs)中,我有以下网格:

<div kendo-grid k-data-source="Table" k-options="thingsOptions" style="height: 365px">

$scope.thingsOptions = {
    sortable: "true",
    scrollable: "true",
    toolbar: [{ name: "create", text: "Aggiungi Prodotto" }],
    columns: [
                { field: "Name", title: "Name", width: "50px" },
                { field: "Description", title: "Description", width: "50px" },
                { field: "Price", title: "Price", width: "50px" },
                { field: "Active", title: "Active", template: '<input type="checkbox" disabled="disabled" #= Active ? checked="checked":"" # class="chkbx"  />', width: "20px" },
                { command: [{ name: "edit", text: "Modifica" }], title: "", width: "172px" }
    ],
    editable: "inline"
};

如何在某些情况下使“价格”字段只读?我必须测试一个变量,如果它是真的,我希望 Price 字段只读,否则可写。

我尝试添加“thingsOptions”功能:

edit: function (e) {
  if(myvar == true)
        e.container.find("input[name=Price]").enable(false);
 }

但是 id 不起作用( undefined reference )。

最佳答案

尝试使用:

edit: function (e) {
    if(myvar == true)
        $("input[name=Price]").attr("readonly", true);
    } else {
        $("input[name=Price]").attr("readonly", false);
    }
}

关于javascript - 剑道 UI 网格 : how to make cell read only on condition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24141773/

相关文章:

javascript - jQuery 如果元素有一个 ID?

javascript - 当用户单击表格的行 <tr> 时将单选标记为已选中

javascript - 如何选择并运行这个onload函数?

javascript - 如何将 $state var 从父状态传递到子状态

Javascript对象按日、月、年分组

javascript - jQuery 计算从 0 到 div 的数字

javascript - 如何使用 RubyMine 4.0 的 'content_for' 帮助程序启用 JavaScript 代码格式化程序

javascript - D3 将鼠标悬停在圆环图切片上时突出显示相应的表格条目

angularjs - ngClass 没有正常工作

javascript - 使用 Ajax 在 ASP.NET MVC 中异步排序 GridView