EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jaimi on January 29, 2015, 05:15:51 AM



Title: disable editor within datagrid
Post by: jaimi on January 29, 2015, 05:15:51 AM
Hi, at specific circumstances I want to deactivate the editor of the field.
How to?
THX,Jaimi

My datagrid:

$('#edgNews').edatagrid({
  title : 'Neuigkeiten',
  iconCls:'icon-Pferd',
  width:'100%', 
  height:'auto',
  collapsible : 'true',

  columns:[[ 
    {field:'OLT30A001T_KEY',title:'PferdKey',width:080,sortable:'true',hidden:'true'}
   ,{field:'OLT30A003T_KEY',title:'NewsKey',width:080,sortable:'true',hidden:'true'}
   ,{field   :'NWS_STATUS'
      ,title   :'Status'
      ,width   :060
      ,sortable:'true'
     , align: 'center'
      ,editor  : {
        type   :'combobox'
      ,options:{
         valueField:'KEY'
        ,textField:'NWS_STATUS'
       ,url:'pferd.lkp.nws.json'
       ,required:true
       ,editable:true
       ,prompt:'Status...'
       ,missingMessage: 'Wählen Sie den Status aus.'
      }
     }//editor
    ,formatter:function(value,row){return value;}//formatter
   }         
   
   ,{field :'NWS_VIDEO',title:'Video',width:75,sortable:'true',hidden:'true'
     ,editor: {type:'textbox', options:{required:false}}
    }
....


Title: Re: disable editor within datagrid
Post by: eagleeye on January 29, 2015, 07:11:50 AM
Use this code

Code:
$('#dg').datagrid({
    onBeforeEdit: function(index,row){
        var col = $(this).datagrid('getColumnOption', 'columnName'); // Here your column name
        if (some condition){
            col.editor = 'text';
        } else {
            col.editor = null;
        }
    }
})


Title: Re: disable editor within datagrid
Post by: gongjw123 on January 29, 2015, 11:43:40 PM
Code:
$('#dg').datagrid({
    onDblClickRow: function(index,row){
    var edType =$(this).datagrid('getEditor',{index:index,field:[font=Verdana]your field[/font]});   
    if([font=Verdana]your condition[/font]){
        $(edType.target).combobox('disable');
    }
})


Title: Re: disable editor within datagrid
Post by: jaimi on February 10, 2015, 09:57:08 PM
thx to all. Jaimi