[英]Selectively switch cells in edit row out of edit mode in Kendo Grid
I am using inline editing in a Kendo (MVC) grid. 我在Kendo(MVC)网格中使用内联编辑。 I have an 'editable' flag to indicate whether in fact a particular cell should indeed be editable.
我有一个“可编辑”标志,以指示实际上某个特定单元格是否确实应该可编辑。 I'm attempting to use the 'closeCell' method to switch out of edit mode:
我正在尝试使用'closeCell'方法退出编辑模式:
On the grid: 在网格上:
.Events(Function(x) x.Edit("onEdit")) _
in js: 在js中:
function onEdit(e) {
//...
$.each(data, function (i, row) {
if (!row.cellEdit) {
e.sender._editContainer[0].cells[i].closeCell;
}
})
}
Whilst the closeCell statement is successfully hit no change appears to be made to the cells edit state. 成功关闭closeCell语句后,似乎对单元格的编辑状态没有任何更改。 What am I missing?
我想念什么?
Ok - much more research later I got something to work. 好的-后来进行了更多研究,我有所作为。 I had been barking up the wrong tree with closeCell() which is for in-cell editing only.
我一直在用closeCell()弄错树,它仅用于单元内编辑。
For those that are interested, the desired behaviour can be achieved by iterating through the cells in the row, which is retrieved using the data-uid: 对于那些感兴趣的人,可以通过遍历该行中的单元格来实现所需的行为,可以使用data-uid检索该单元格:
$.each(data, function (i, row) {
if (!row.cellEdit) {
var uid = e.container.attr('data-uid');
var thisRow = $('tr[data-uid="' + uid + '"]');
var thisCell=$(thisRow).find('td').eq(i);
thisCell.find('input').prop('disabled', true);
This doesn't take the cell out of edit-mode but it does make it read-only which is near enough what I needed. 这不会使单元格脱离编辑模式,但会使其变为只读状态,这已经足够我所需。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.