2013-06-18 77 views
1

我现在已经另一个大问题,我贴我的代码,然后我问我的问题Ext JS的beforeedit

var gridTablaConsulta = Ext.create('Ext.grid.GridPanel', { 
    title:'Consulta Tabla lotes', 
    id:'gridTabla', 
    store: storeTabla, 
    columns: [ 
     Ext.create('Ext.grid.RowNumberer'), 
     {text: "NRBE", width: 60, sortable: true, dataIndex: 'NRBE'}, 
     {text: "APLIC", width: 60, sortable: true, dataIndex: 'APLIC'}, 
     {text: "FORM", width: 60, sortable: true, dataIndex: 'FORM'}, 
     {text: "VERFOR", width: 60, sortable: true, dataIndex: 'VERFOR'}, 
     {text: "FECLOT", width: 60, sortable: true, dataIndex: 'FECLOT'}, 
     {text: "HORLOT", width: 60, sortable: true, dataIndex: 'HORLOT'}, 
     {text: "TIPPAPLO", width: 60, sortable: true, dataIndex: 'TIPPAPLO'}, 
     {text: "TAMPAP", width: 60, sortable: true, dataIndex: 'TAMPAP'}, 
     {text: "FECINIIM", width: 60, sortable: true, dataIndex: 'FECINIIM'}, 
     {text: "FECINIOB", width: 60, sortable: true, dataIndex: 'FECINIOB',editor:  {xtype:'textfield', allowBlank:true}}, 
     {text: "ESTLOT", width: 60, sortable: true, dataIndex:'ESTLOT',editor:{xtype:'textfield', allowBlank:true}}, 
     {text: "TOTPAGGE", width: 60, sortable: true, dataIndex: 'TOTPAGGE'}, 
     {text: "TOTPAGIM", width: 60, sortable: true, dataIndex: 'TOTPAGIM'}, 
     {text: "DESLOT", width: 60, sortable: true, dataIndex: 'DESLOT'}, 
     {text: "TIPDIF", width: 60, sortable: true, dataIndex: 'TIPDIF'}, 
     {text: "DIADIF", width: 60, sortable: true, dataIndex: 'DIADIF'}, 
     {text: "FECALT", width: 60, sortable: true, dataIndex: 'FECALT'}, 
     {text: "FECMOD", width: 60, sortable: true, dataIndex: 'FECMOD'}, 
     {text: "TERMOD", width: 60, sortable: true, dataIndex: 'TERMOD'}, 
     {text: "HORMOD", width: 60, sortable: true, dataIndex: 'HORMOD'} 
    ], 
    selType: 'rowmodel', 
    plugins: [ 
     Ext.create('Ext.grid.plugin.RowEditing', { 
      clicksToEdit: 2 
     }) 
    ], 

    listeners: { 

     beforeedit: function(editor, e, eOpts) { 
      var grid = Ext.getCmp('gridTabla'); // or e.grid 
      if (e.record.data.ESTLOT === '02') { 
       e.cancel = true; //no permite 
      } else { 
       e.cancel = false; //permite 
      } 
      if (e.record.data.ESTLOT === '01') { 
       e.cancel = false; //no permite 
      } 


     }, 

     edit: function(e, context){ 
      var record = context.record; 
      var recordData = record.getData(); 
      recordData.Funcionalidad = 'Modificar'; 
      alert(JSON.stringify(recordData)); 
      Ext.Ajax.request({ 
       url: 'http://localhost:8080/MyMaver/ServletTablaLotes', 
       method: 'POST', 

       // merge row data with other params 
       params: recordData 
      }); 
     } 
     } 
}); 

好了,现在我的问题,问题是,在我的beforeedit,我需要检查的条件这允许我将字段“ESTLOT”更改为另一个取决于先前值的值,例如,如果ESTLOT值为04和05,那么该字段ESTLOT可以是01或03,但是如果值为06或03,它可以是04或05.我的问题是,我不知道谁来评估这种情况,因为在编辑之前,我有以前的值,但在编辑我已经改变了值...

Anyboby can帮我?感谢所有。

回答