【问题标题】:How to disable edit from kendo editable grid dynamically?如何动态禁用剑道可编辑网格的编辑?
【发布时间】:2016-06-29 05:21:56
【问题描述】:

我想只禁用剑道可编辑网格的第一个单元格的编辑,我正在做类似下面的事情。实际上我正在尝试删除日期选择器 从剑道网格的第一个单元格开始,因为它不需要在那里。所以我在下面使用,这段代码从网格中删除了 datepicker,但它仍然显示一个文本框。 我应该可以完全删除它。

  function onGridEditing(e) {
        var gridbody = $("#EditableGrid").data("kendoGrid");
        var gridData = gridbody.dataSource.view();
        var currentUid = gridData[0].uid;
        var Date = gridData[0].Date;
        var currenRow = gridbody.table.find("tr[data-uid='" + currentUid + "']");
        //var firstCell = currenRow.find('td:not(:empty):first');
        //firstCell.find('.k-select').remove();
        //alert(firstCell.val());
        currenRow.find('.k-select').remove();// this removes the datepicker but it is still showing textbox when user click on the row for edit.
        currenRow.find(".editDate").remove();

ALso I tried to apply a css over there so that it hide datepicker but not working
//$("#EditableGrid").data("kendoGrid")._data[0].addClass('hideMe');
    }

<style>

   .hideMe {
        /*visibility: hidden;*/
        border: none !important;
        background-color: none !important;
    }

</style>

【问题讨论】:

标签: jquery kendo-ui kendo-grid kendo-datepicker


【解决方案1】:

您可以禁用对数据源模型中特定列的编辑。例如:

model: {
    fields: {
        ProductID: {
            //this field will not be editable (default value is true)
            editable: false
        }
    }
}

来源:Telerik Forums

编辑:动态进行:

var model = $("#EditableGrid").data("kendoGrid").dataSource.getByUid(currentUid);
if (model) {
    model.fields["ProductID"].editable = false;
}

【讨论】:

  • 但这会禁用整列。我只想在一行的第一个单元格上禁用编辑,而不是在其他单元格上。
猜你喜欢
  • 2013-01-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多