javascript - Kendo ui 添加新记录时禁用列

标签 javascript kendo-ui radio-button kendo-grid

如何实现此目的,我想仅在添加新记录并选中时禁用状态列上的单选按钮。

enter image description here

我不知道我应该给出脚本的哪一部分。但我在这里提供了一些。

我的 KendoGrid 脚本

        $("#grid").kendoGrid({
        dataSource: dataSource,
        dataBound: setColor,
        height:400,
        sortable: true,

        columns: [ 
            { field: "segmentActive", title:"STATUS", width: "120px", editor: RadioSegmentActive, 
              template: data => data.segmentActive == "y" ? "Yes" : "No" }, // <-- displaying Yes/No insted of y/n

            { field: "marketSegmentName", title:"SEGMENT NAME", width: "120px" },

            { field: "publicPrice", title:"PUBLIC PRICE", width: "120px", editor: RadioPublicPrice,
              template: data => data.publicPrice == "y" ? "Yes" : "No"},

            { field: "isHouseUse", title:"HOUSE USE", width: "120px", editor: RadioHouseUse,
              template: data => data.isHouseUse == "y" ? "Yes" : "No"},

            { command: ["edit",{ name: "destroy", text: "De-active" }], title: "&nbsp;", width: "120px" },
        ],
        editable: "inline",
        ...........

我的RadioSegmentActive函数

function RadioSegmentActive(container, options) {
var guid = kendo.guid();

    $('<input class="k-radio" id="radio3" name="segmentActive" type="radio" value="y" >').appendTo(container);
    $('<label class="k-radio-label" for="radio3">YES</label>').appendTo(container);  //YES
    $('<br>').appendTo(container); 
    $('<input class="k-radio" id="radio4" name="segmentActive" type="radio" value="n" >').appendTo(container);
    $('<label class="k-radio-label" for="radio4">NO</label>').appendTo(container);  //NO        
}

最佳答案

我不确定“检查是”是什么意思,但您可以通过处理 edit event 来做到这一点网格:

editable: "inline",
edit: function(e) {
    if (e.model.isNew()) { // We are adding
        // if ($("#radio3").prop("checked")) {  // Check some field...
        $("#radio3").attr('checked', true);  // Set yes radio button
        $('input[name=segmentActive]').attr("disabled",true);  // Disable radio buttons
        // }
    }
}

关于javascript - Kendo ui 添加新记录时禁用列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54000404/

相关文章:

python-3.x - 带单选按钮的 flask handle 形式

javascript - 将 C 翻译成 JavaScript

javascript - 滚动标题

javascript - 如何禁用动态创建的 <li> 元素?

javascript - 使用 Kendo MVC 上传控件将 Javascript/html 变量作为参数传递

javascript - 与 KendoUI 网格一起使用的 JS 上下文菜单

kendo-ui - 如何在 Kendo TreeView 中查找嵌套节点,其中数据为 'lazely' 通过 web-api 提供

javascript - 在先前选择的同名单选按钮上调用函数

java - 将单选按钮值从一个类传递到另一个类

javascript - ElectronJS BrowserWindow FOUC