简体   繁体   中英

Selectively switch cells in edit row out of edit mode in Kendo Grid

I am using inline editing in a Kendo (MVC) grid. 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:

On the grid:

 .Events(Function(x) x.Edit("onEdit")) _

in 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. 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.

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:

 $.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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM