阻止用户单击kendo网格中的其他单元格

时间:2016-11-09 13:20:31

标签: user-interface kendo-ui

我有剑道儿童网格。它有一些排。每行都有一些细胞。如果我改变第一行以外的单元格的值,我必须获得相应的第一行单元格值并进行一些验证。见附图

enter image description here

代码

 var $container = $(container),
        tdIndex = $container.index(),
        $correspondingCell = $container.closest("tbody").find("tr:first td:eq(" + tdIndex + ")");
            $('<input  maxlength="9" data-bind="value:' + options.field + '"/>')
                .appendTo($container)
                .kendoNumericTextBox({
                    format: "0.####",
                    decimals: 0,
                    min: 0,
                    spinners: false,
                    change: function (e) {
                        //debugger;
                        CalculateFormatWeeks(options.model);
                        var uid = options.model.uid;
                        var cellinx = $('#kenTitleFormatsGrid .k-edit-cell')[0].cellIndex;
                        var row = $("#kenTitleFormatsGrid tbody").find("[data-uid='" + uid + "']");
                        var cell = row.children().eq(cellinx);
                        cell.css("font-style", "normal");
                        console.log("From Cell", $correspondingCell.text());
                        if (Number($correspondingCell.text()) == 0) {
                            alert("There is no daily GBO exists to enter the format gross. Please add the daily GBO data before proceeding");
                        }
                    }                        
                }).off("keydown");

2 个答案:

答案 0 :(得分:0)

为Grid的save事件添加一个处理程序,并在需要时使用grid.editCell()方法,即:

save: function (e) {
    var $container = $(e.container),
        tdIndex = $container.index(),
        $correspondingCell = $container.closest("tbody").find("tr:first td:eq(" + tdIndex + ")");

    if (Number($correspondingCell.text()) == 0) {
        alert("There is no daily GBO exists to enter the format gross. Please add the daily GBO data before proceeding");
        e.sender.editCell($container);
    }
  }

演示:http://dojo.telerik.com/@Stephen/EDeFO

答案 1 :(得分:0)

试试吧 脚本级别

function CloseEditable(e) {    
        this.closeCell();      

}

查看级别

事件(events =&gt; events.Edit(“CloseEditable”)

如果你想要关闭特定的单元格,那么得到单元格的cellIndex