2016-06-29 121 views
0

我想禁用编辑kendo编辑网格的第一个单元格,我正在做类似下面的操作。其实我试图从kendo网格的第一个单元格删除日期选择器 ,因为它不需要在那里。所以我使用下面,这段代码从网格中删除datepicker,但它仍然显示一个文本框。 我应该能够完全删除它。如何从博科动态编辑kendo编辑网格

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> 
+0

上编辑的事件,你可以只隐藏整列,如果不使用'格了。 hideColumn(0);' –

+0

http://stackoverflow.com/questions/20881484/make-cell-readonly-in-kendo-grid-if-condition-is-met – calinaadi

回答

0

您可以禁用编辑dataSource模型中的特定列。例如:

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; 
} 
+0

但是,这将禁用整个列。我只想在一行的第一个单元格中禁用编辑,而不是在其他单元格中编辑。 – Sandy

+0

我编辑了我的答案 – mrmashal