2

My problem is that i want to change the cell being editable or not in the edit form according to the content of the cell of the row that is selected to be edited. I used Oleg's example to this link: JQGrid: Dynamically set a cell to uneditable based on content to figure out how to change the cell from editable to not editable but i cannot get the cell value in order to compare it and decide if i want to change the edit option of the cell.

UPDATED CODE:

var Setcelluneditable=function(form) {
        return function (form) {
        var id = jQuery(list).getGridParam('selrow');
        var ret = jQuery(list).jqGrid('getRowData',id);
        alert("Arrived="+ret.Arrived);
        if (ret.Arrived=='Yes')
         {alert("hello"+id);
         jQuery(list).setCell(id,'Arrived','',{color:'red'}, editable:'0'});}
     }
     }; 

jQuery(list).jqGrid('navGrid',pager,{edit:true,add:true,del:true,search:false,view:true, reload:true},
                {
                    width:colwidth,
                    height:"auto",
                    reloadAfterSubmit:true,
                    closeAfterEdit: true,
                    recreateForm: true,
                    ajaxEditOptions: {cache: false},
            beforeInitData : Setcelluneditable("#editmod")
                },
                {
                            width:colwidth,
                            height:"auto",
                            reloadAfterSubmit:true,
                            closeAfterAdd: true,
                            recreateForm: true,
                            drag: false
                },
                {},
                {},
                {},
                {}); 

This does not seem to work because i change the Grid that has already been constructed.

Community
  • 1
  • 1
ilektrologaki
  • 95
  • 1
  • 1
  • 8

2 Answers2

6

I think i found out the way to do that but it does not seem to me the best one can have:

onSelectRow: function(id){ 
        var ret = jQuery(list).jqGrid('getRowData',id);
        if (ret.Arrived=='Yes')
         {
            jQuery(list).setColProp('Arrived',{editable:false});}
        else {  jQuery(list).setColProp('Arrived',{editable:true});}}

I change the ColProp every time one Selects a Row.

ilektrologaki
  • 95
  • 1
  • 1
  • 8
0
selRowId = $(list).jqGrid ('getGridParam', 'selrow');
var cm = $(list).jqGrid('getGridParam', 'colModel');
for(x=0; x<cm.length; x++){
    if(cm[x].name == 'ID'){
        $('#' + selRowId + '_' + cm[x].name).attr('disabled', true);
    }
}

code in onSelectRow event