0

GRID パネルのレコードのフィールドの値を取得するにはどうすればよいですか? 私は次のコードを持っています:

   var gridTablaConsulta = Ext.create('Ext.grid.GridPanel', {
    title:'Consulta Tabla lotes',
    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: {
             scope: this,
             fn: function(e, context2){
                 var record2= context2.record;
                 var recordData2=record2.getData();
                 alert(JSON.stringify(recordData2));

             }
         },

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

レジスタにグリッドとパルスを表示すると、フィールド「ESTLOT」の値を評価できるようになり、前の値に応じてその値が変更されます。

私の問題は、そのレジスタの一部であるすべてのフィールドを誰が取得するかだけを知っていることですが、ESTLOT 値のみが必要であり、この値を編集機能に渡し、そこで値を評価します。

たくさんの助けが必要です。

EDIT2:

 listeners: {

        beforeedit: function(editor, e, eOpts) {
            var grid = Ext.getCmp('gridTabla'); // or e.grid
            var hoy = new Date();

            dia = hoy.getDate(); 

            if(dia<10)
                {
                    dia=String("0"+dia);

                }

            mes = hoy.getMonth();

            if(mes<10)
            {
                    mes=String("0"+mes);

            }
            anio= hoy.getFullYear();
            fecha_actual = String(anio+""+mes+""+dia);
            //alert(fecha_actual);

            var mola = e.record.data.ESTLOT;
            alert(mola);

            if (e.record.data.ESTLOT === '02') {
                if (e.record.data.FECMOD === fecha_actual)
                 {
                e.cancel = false; //permite
                 }
                else{
                    e.cancel = true;
                }

            }  else
            {
                e.cancel = false; //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 に含まれる var = "mola" を渡したいと思います

EDIT 3 新しいコードと失敗

      listeners: {

        beforeedit: 

            function preditar(editor, e, eOpts, mola) {
            var grid = Ext.getCmp('gridTabla'); // or e.grid
            var hoy = new Date();

            dia = hoy.getDate(); 

            if(dia<10)
                {
                    dia=String("0"+dia);

                }

            mes = hoy.getMonth();

            if(mes<10)
            {
                    mes=String("0"+mes);

            }
            anio= hoy.getFullYear();
            fecha_actual = String(anio+""+mes+""+dia);
            //alert(fecha_actual);

            var mola = e.record.data.ESTLOT;
            //alert(mola);
            editar(mola);

            if (e.record.data.ESTLOT === '02') {
                if (e.record.data.FECMOD === fecha_actual)
                 {
                e.cancel = false; //permite
                 }
                else{
                    e.cancel = true; //mo permite
                }

            }  else
            {
                e.cancel = false; //permite
            }

        },

         edit:

             function editar(e, context, mola){

             var record = context.record;
             var recordData = record.getData();
             var mola2= mola;
             alert(mola2);
             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
             });
         }
        }
});

「レコードはnullです。オブジェクトではありません」と言って、ここに表示されます: var record = context.record;

再度、感謝します。

4

2 に答える 2

1

Sencha: before編集

e : オブジェクト 次のプロパティを持つ編集イベント:

value - 編集中のフィールドの値。

listeners: {
     beforeedit: {
         scope: this,
         fn: function(e, context2){ 
            if(e.value=="ESTLOT"){
              alert("value: " + e.value);
            }
         }
     },
...
}

編集:

どこで値をキャッチしたいのかよくわかりませんが、コントローラーの別のケース:

キャッチイベント:

'gridView column[action=columnActionName]' : {
    click : me.funcitonInspect
},

関数:

funcitonInspect : function(grid,el,rowIndex){
    var grid = Ext.ComponentQuery.query('grid')[0];
    var selection = grid.getSelectionModel();
    if(selection.hasSelection()){
        var modeloSelected = selection.getLastSelected();
        if(modeloSelected.data.NameField=="ESTLOT"){
               ...
            }
    }
},

EDIT2: FireEvent の使用

beforeEdit で "fireevent" を実行できるかもしれません:

this.fireEvent('edit', e, context); 

一例:

編集3:

次の値を取得してみてください: var record = e.record; 2 番目のパラメータは eOpts (オプション オブジェクト) です - 次の説明を参照してください: sencha doc

例:

edit:

    function editar(e, context, mola){
        var record = e.record;
        ...
    }
},
于 2013-06-17T12:26:01.940 に答える
0

これが完全な解決策です。全てに感謝。

    listeners: {

        beforeedit: 

            function preditar(editor, e, eOpts) {
            var grid = Ext.getCmp('gridTabla'); // or e.grid
            var hoy = new Date();
            dia = hoy.getDate();  
            if(dia<10)
                {
                    dia=String("0"+dia);

                }
            mes = hoy.getMonth();
            if(mes<10)
            {
                    mes=String("0"+mes);
            }
            anio= hoy.getFullYear();
            fecha_actual = String(anio+""+mes+""+dia);
            e.record.beforeEditESTLOT = e.record.data.ESTLOT;
            if (e.record.data.ESTLOT === '02') {
                if (e.record.data.FECMOD === fecha_actual)
                 {

                    e.cancel = false; //permite probar mañana con cambio fecha
                 }
                else{
                    alert("Solo puedes modificar este estado en lotes modificados en el día actual");
                    e.cancel = true; //no permite
                }

            }  else
            {
                e.cancel = false; //permite
            }

        },

         edit:
             function editar(e, context){
             var record = context.record;
             var recordData = record.getData();
             recordData.Funcionalidad = 'Modificar';
             var modificado = record.modified.ESTLOT; //valores anteriores
             //alert(modificado);
             //var nuevo = recordData.ESTLOT;
             //var cadena = JSON.stringify(recordData);
             //alert(cadena);
             var prueba = context.record.data.ESTLOT;//valores nuevos
             //alert(prueba);
             if ((modificado==='06')||(modificado==='03'))
             {

                 if ((prueba==='01')||(prueba==='02')||(prueba==='03')||(prueba==='06'))
                     {
                     Ext.Ajax.request({
                         //url: 'http://localhost:8080/MyMaver/ServletTablaLotes',
                         url: 'http://lnxntf05:8080/MyMaver/ServletTablaLotes',
                         method: 'POST',
                         // merge row data with other params
                         params: recordData
                     });
                     alert("Modificacion realizada correctamente");
                     }
                 else
                     {

                        alert("Si el valor anterior de estado de lote es 06 o 03 no puede pasar a valer 04 o 05");

                     }   
             }
             if ((modificado==='04')||(modificado==='05'))
             {

                 if ((prueba==='02')||(prueba==='04')||(prueba==='05')||(prueba==='06'))
                     {
                     Ext.Ajax.request({
                         //url: 'http://localhost:8080/MyMaver/ServletTablaLotes',
                         url: 'http://lnxntf05:8080/MyMaver/ServletTablaLotes',
                         method: 'POST',
                         // merge row data with other params
                         params: recordData
                     });
                     alert("Modificacion realizada correctamente");
                     }
                 else
                     {

                        alert("Si el valor anterior de estado de lote es 04 o 05 no puede pasar a valer 01 o 03 o en blanco");

                     }   
             }

             if(modificado==='01')
                 {
                 if ((prueba==='02')||(prueba==='03')||(prueba==='04')||(prueba==='05')||(prueba==='06'))
                 {
                     Ext.Ajax.request({
                     //url: 'http://localhost:8080/MyMaver/ServletTablaLotes',
                     url: 'http://lnxntf05:8080/MyMaver/ServletTablaLotes',
                     method: 'POST',
                     // merge row data with other params
                     params: recordData
                 });
                     alert("Modificacion realizada correctamente");
                 }

                 else
                     {
                     alert("Insertad un valor valido");

                     }

                 }
             if(modificado==='  ')
                 {
                 if ((prueba==='02')||(prueba==='01')||(prueba==='03')||(prueba==='04')||(prueba==='05')||(prueba==='06'))
                 {
                     Ext.Ajax.request({
                     //url: 'http://localhost:8080/MyMaver/ServletTablaLotes',
                     url: 'http://lnxntf05:8080/MyMaver/ServletTablaLotes',
                     method: 'POST',
                     // merge row data with other params
                     params: recordData
                 });
                     alert("Modificacion realizada correctamente");
                 }
                 else
                     {
                     alert("Insertad un valor valido");

                     }

                 }

         }
        }
});
于 2013-06-19T10:10:44.967 に答える