求教:修改下这个JS

文本框小数测试.cpt

日志抛出错误

严重:16:00:36 http-nio-8075-exec-7 ERROR [standard] 错误代码:11201000 JS抛错

具体错误:Cannot read property 'getValue' of null

错误堆栈:TypeError: Cannot read property 'getValue' of null

    at FR.WLGP.stopCellEditing (http://localhost:8075/webroot/decision/view/report?viewlet=11111111.cpt&op=write:358:22)

    at FR.WLGP.selectTDCell (http://localhost:8075/webroot/decision/view/report?viewlet=11111111.cpt&op=write:342:487)

    at sb.eval (eval at

    at sb.

    at eval (eval at

    at sb.eval (eval at jsonDecode (http://localhost:8075/webroot/decision/view/report?op=emb&resource=finereport.js&inter=zh_CN&__fr_locale__=&__v__=2020.11.13.20.06.57.429&jsVersion=1606357053392:533:290),

    at Object.tc (http://localhost:8075/webroot/decision/view/report?op=emb&resource=finereport.js&inter=zh_CN&__fr_locale__=&__v__=2020.11.13.20.06.57.429&jsVersion=1606357053392:501:111)

    at sb.action (eval at jsonDecode (http://localhost:8075/webroot/decision/view/report?op=emb&resource=finereport.js&inter=zh_CN&__fr_locale__=&__v__=2020.11.13.20.06.57.429&jsVersion=1606357053392:533:290),

    at sb.

    at sb.fireEvent (http://localhost:8075/webroot/decision/view/report?op=emb&resource=finereport.js&inter=zh_CN&__fr_locale__=&__v__=2020.11.13.20.06.57.429&jsVersion=1606357053392:566:127)



1606809773(1).jpg


var endrate = this.getValue();

var cell = contentPane.curLGP.getTDCell(1, 1);

contentPane.curLGP.selectTDCell(cell);

var a = this.getValue();

var location = this.options.location; //获取当前控件的位置

var cr = FR.cellStr2ColumnRow(location);

var col = cr.col; //列号

var ro = cr.row; //行号

//这里是正则表达式在js里的判断用法

if (/^\d+(\.\d{1,2})?$/.test(endrate)) {} else {

    alert("课消请输入精度为两位小数以内的正数!");

    contentPane.setCellValue(col, ro, "0.00");

}


原始的需求是这个文本框输入小数过后超过2位小数就弹出提示


1606809950(1).jpg 一直在加载处理中

Zero丶zero 发布于 2020-12-1 16:04 (编辑于 2020-12-1 16:10)
1min目标场景问卷 立即参与
回答问题
悬赏:4 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共1回答
最佳回答
1
luojian0323Lv7资深互助
发布于2020-12-1 16:08(编辑于 2020-12-1 16:28)

image.png



代码正常

var endrate = this.getValue();
//var cell = contentPane.curLGP.getTDCell(1, 1);
//contentPane.curLGP.selectTDCell(cell);
var location = this.options.location; //获取当前控件的位置
var cr = FR.cellStr2ColumnRow(location);
var col = cr.col; //列号
var ro = cr.row; //行号
//这里是正则表达式在js里的判断用法
if (/^\d+(\.\d{1,2})?$/.test(endrate)) {} else {
    alert("课消请输入精度为两位小数以内的正数!");
    contentPane.setCellValue(col, ro, "0.00");
}

不知道你那个选择单元格有何义,去掉就不报错了。

image.png

  • 2关注人数
  • 504浏览人数
  • 最后回答于:2020-12-1 16:28
    请选择关闭问题的原因
    确定 取消
    返回顶部