0

I have grid with several editable cols

colModel: [
    { 
        name: 'id',
        width: 1,
        hidden: true,
        key: true,
        resizable: false
    },
    {
        name: 'name',
        editable: true,
        sortable: false,
        resizable: false
    },
    {
        name: 'name2',
        editable: true,
        sortable: false,
        resizable: false
    },
    treeGrid: true,
    treeGridModel: 'adjacency',
    ExpandColumn: 'name',

For some reason I'm needed to have some not editable cells in these cols

    loadComplete: function() {
        var ids = grid.jqGrid('getDataIDs');

        for (var i=0;i<ids.length;i++) {
            var id=ids[i];
            var row_data = $(this).jqGrid('getRowData', id);

            if (row_data.zzz > 0) {
                if (row_data.zzz > 1) 
                    grid.jqGrid('setCell',id,'name2','','not-editable-cell');
                else
                ...
            }
            else {
                grid.jqGrid('setCell',id,'name','','not-editable-cell');
                ...
            }
        }
    }

So some rows have both cells editable(name, name2), some only one (name or name2)

I don't have any problems If I use editCell But editRow doesn't pay attention on not-editable-cell class

I've solved this problem by editing of jquery.jqGrid.src.js I understend that it's very bad way

$.jgrid.extend({
//Editing
    editRow : function(rowid,keys,oneditfunc,successfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc) {
.......
        return this.each(function(){
            var $t = this, nm, tmp, editable, cnt=0, focus=null, svr={}, ind,cm;
            if (!$t.grid ) { return; }
            ind = $($t).jqGrid("getInd",rowid,true);
            if( ind === false ) {return;}
            editable = $(ind).attr("editable") || "0";
            if (editable == "0" && !$(ind).hasClass("not-editable-row")) {
                cm = $t.p.colModel;
                $('td[role="gridcell"]',ind).each( function(i) {
///
                    if (!$(this).hasClass("not-editable-cell")) {
///
                    nm = cm[i].name;
                    var treeg = ($t.p.treeGrid===true && nm == $t.p.ExpandColumn) ? true : false;

Is it possible to solve this problem via formatter?

dr0zd
  • 1,368
  • 4
  • 18
  • 28

1 Answers1

1

The class "not-editable-cell" are really used only in the cell editing. The inline editing analyse "not-editable-row" call only. You can change the source code of jqGrid, but you will receive problems to maintain your custom changes after releasing of the new version of jqGrid. So the better way is to post you suggestion in the trirand forum.

As a workaround you can use the trick which I described here and here. The idea is easy: you can temporary modify the editable property based on the cell contain. Directly after you call of editRow method you can reset editable property because the editing fields already created.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798