2012-01-18 8 views
2

제 문제는 선택된 행의 셀 내용에 따라 편집 가능한 셀을 편집 할 것인지 변경하려고하는지입니다. 편집 할 수 있습니다. Oleg의 예제를이 링크에 사용했습니다 : JQGrid: Dynamically set a cell to uneditable based on content 편집 가능한 셀을 편집 할 수 없도록 변경하는 방법을 알아 내기 위해 셀 값을 가져올 수 없습니다. 셀 값을 비교하여 셀의 편집 옵션을 변경할지 결정합니다.jqgrid : 편집 가능한 셀을 양식 편집의 셀 값에 따라 편집 할 수 없도록 변경하십시오.

업데이트 된 코드는 :

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 
       }, 
       {}, 
       {}, 
       {}, 
       {}); 

이 이미 구축 된 그리드를 변경하기 때문에 작동하지 않습니다.

답변

5

나는 내가 그렇게 할 수있는 방법을 찾은 것 같아하지만 최고의 하나가 가질 수있는 나에게하지 않는 것 :

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});}} 

내가 ColProp 하나가 행을 선택합니다 모든 시간을 변경합니다. onSelectRow 이벤트

+0

정말 많은 도움이 – Habeeb

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); 
    } 
} 

코드는

관련 문제