Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在js中的函数之间传递参数时失败_Javascript_Extjs_Param - Fatal编程技术网

Javascript 在js中的函数之间传递参数时失败

Javascript 在js中的函数之间传递参数时失败,javascript,extjs,param,Javascript,Extjs,Param,当我启动应用程序时,会出现下一个故障:“记录为空或不是对象”,出现在下一行“var record=context.record”;有人可以解释或找到故障。。。我尝试将变量“mola”从beforeedit传递到edit函数 我的代码是下一个: listeners: { beforeedit: function preditar(editor, e, eOpts, mola) { var grid = Ext.getCmp('g

当我启动应用程序时,会出现下一个故障:“记录为空或不是对象”,出现在下一行“var record=context.record”;有人可以解释或找到故障。。。我尝试将变量“mola”从beforeedit传递到edit函数

我的代码是下一个:

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
             });
         }
        }
});
侦听器:{
编辑前:
函数preditar(编辑器、e、eOpts、mola){
var grid=Ext.getCmp('gridTabla');//或e.grid
var hoy=新日期();
dia=hoy.getDate();

如果(dia问题不在于
mola
变量,而在于
e.record
。如错误消息所述,变量
e
不包含对象
record
e.record
null
。尝试
console.log(e)
进一步检查变量
e

您正在使用

editar(mola);
但该功能定义为:

editar(e, context, mola)

因此,该函数只接收e参数,其他参数设置为未定义。

您使用单参数调用函数。editar(mola)所以context和mola在函数中是空的好吧,我想问题是这样的,但是我怎么解决这个问题呢?既然没有任何对“context”的引用,那么你可能想试试看eOpts是否有效或者它可能是“grid”。我不知道,你需要检查这些变量是否包含一个名为“record”的对象。使用brows当我没有函数时,mi代码工作正常,然后记录有任何值,我在alart中看到,我的问题实际上是在我尝试此警报(JSON.stringify(recordData))时,在Java中的函数之间传递var;我获得了该字段中包含的正确信息……我认为555k是正确的,因为如果a退出两个函数中的参数mola,我的程序将正常运行,但当我尝试在两个函数之间传递var时,是出现故障时,我尝试使用var mola=e.record.data.ESTLOT;//警报(mola);editar(e,context,mola);但出现下一个故障“context未定义”我的问题有什么解决方案吗?