按照文档操作,进行JS数据导出时,报错customJS Error:cannot read properties of undefined(reading 'getWidgetByname'), 具体JS: var widgetNames = ['nev_type', 'syear','sweek','fuel','groupsub','brand','category','subdivision','import', 'department','model','netdistrict','province','city','price_range_s','price_range_b']; //定义数组存放控件名称 function getWidgetValueByName(name) { var widget = _g().parameterEl.getWidgetByName(name); //根据控件名获取控件值 if (widget == undefined) return; var obj = {}; obj[name] = widget.getValue(); return obj; //返回控件值组成的数组 } var paramJson = widgetNames.map(getWidgetValueByName).reduce(function(a, b) { return Object.assign(a, b) }); var paramJsonStr = JSON.stringify(paramJson); //将json数据转换为字符串 var col = _g().getParameterContainer().getWidgetByName("col").getValue(); //alert(col); //参数进行url编码 var colNames = encodeURIComponent(col) //var colNames = encodeURIComponent() //指定导出的数据列,导出字段按此顺序排列,为空默认导出所有 //调用导出接口 //console.log(paramJsonStr); //console.log(colNames); _g().directExportToExcel("ds1", "明细数据", encodeURIComponent(paramJsonStr), colNames," "," "); |