0

I thought I could use the event gridInitialized an run loop through the id's of each row adding the class 'non-editable-cell' but the class is added but when the row is put into edit mode the cells with the class are still editable.

function gridInitialized() { var grid = jQuery('#enabledLanguagesGrid'); 
    var ids = grid.getDataIDs(); 
    for(var i = 0; i < ids.length; i++)  
        var id = ids[i]; 
        if (grid.getCell(id, 'isCustom') === 'True') {
            grid.setCell(id, 'name', '', 'not-editable-cell')
        } 
    } 
}

When I use grid.editRow to enter edit mode the name field is still editable.

On another note, I am not receiving any replies on the trirand.net public forum or on the support email address. It's been 8 days since my first contact with them. Anybody else experiencing problems with support at Trirand?

Many thanks

Simon Ryan
  • 212
  • 1
  • 9

1 Answers1

1

Please include in all your question the information about the version of jqGrid, which you use (can use), and about the fork (free jqGrid, commercial Guriddo jqGrid JS or an old jqGrid in version <=4.7).

It's important to understand, that jqGrid has 3 alternative editing modes: inline editing, form editing and cell editing. The class not-editable-cell will be used only by cell editing. You wrote about the editRow, which is part of inline editing. It supports``not-editable-row` class, which can be set on rows to prevent the whole row be editable.

The implementation of your requirements heavy depend on your exact requirements and on the version of jqGrid, which you use. The most easy solution exist if you use free jqGrid fork, which I develop starting with the end of 2014 (after making the main fork commercial and renaming it to Guriddo jqGrid JS). Free jqGrid allows to define editable property of the column as callback function. The feature is described in the wiki article. The callback function has rowid as the parameter and one can get the data of the row, analyse the data and to return true/false (allow or not allow to edit the cell) depend on any custom criteria. The editable property as callback is implemented for all editing modes.

If you have to use old version of jqGrid then you should follow the solution described in the old answer or in this one. You can implement the solution in easy way only if you call editRow directly. The solution for indirect usage of editRow (by inlineNav or formatter: "actions") is much more complex.

The final remark. You should try never use the code like gridInitialized, which you posted, because it modifies the data on the page in the loop. It's important to understand, that modifying of one element on HTML page follows web browser reflow. The web browser have to recalculate or to change the position or other properties of all existing elements on the page. Thus you essentially increase the complexity of the code and reduce the performance of your page if you modify elements on the page. I'd recommend you to read the old article and to use cellattr, rowattr and custom formatters instead of changing the data in the loop.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thank so much for the useful information I am using the MVC version from trirand.net version 5.2.0. I wish to disable certain cells during row editing depending on the value of one of the other cells in the row being edit. – Simon Ryan Mar 21 '17 at 10:02
  • @SimonRyan: Guriddo jqGrid JS is **commercial** version (see the license and the prices [here](http://guriddo.net/?page_id=103334)). I develop alternative fork, which I provide completely free of charge. I provide of cause no support for Guriddo. I can address you only to [Guriddo forum](http://guriddo.net/?forum=guriddo-js). The only way, which I can suggest you, is following to [my old answer](http://stackoverflow.com/a/4308172/315935), which I referenced in my answer. – Oleg Mar 21 '17 at 10:06
  • Thank you. We may change to your fork as the apparent 'support' has not materialised from that company :( – Simon Ryan Mar 21 '17 at 10:11
  • @SimonRyan: I provide free jqGrid under old MIT/GPL-licenses, which allows you to make your own fork at any time and develop your fork independently starting with the point. I can't suggest you more. I recommend you to look though the features implemented in free jqGrid. See [the page](https://free-jqgrid.github.io/getting-started/index.html), [the wiki](https://github.com/free-jqgrid/jqGrid/wiki) and the readmes to all previously published versions. For example, the last one provides [the demo](https://jsfiddle.net/OlegKi/yvbt6w54/1/) which demonstrates the last implemented features. – Oleg Mar 21 '17 at 10:17