Question

when i launch my applicattion appears the next failure: "record is null or is not an object", appears in the next line " var record = context.record;" Somebody could explain or find the failure... i try to pass the var "mola" from beforeedit to the edit function...

My code is the next:

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
             });
         }
        }
});
Was it helpful?

Solution

You are calling the function with

editar(mola);

But the function is defined as:

editar(e, context, mola)

So the function only receives the e parameter and the others are set to undefined.

OTHER TIPS

the problem is not the mola variable but e.record. As your error message states the variable e either does not contain an object record or e.record is null. Try to console.log(e) to inspect your variable e further.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top