问题描述:

页面端用了easyui的numberbox属性,然后在用js的方法修改值的时候,明明看到页面中的值是数字型(数量字段),

但是就是会报错

这种错误真的是很难理解,不过经过我的debug跟了一下,发现了问题所在,虽然页面中看到的是数字,但是在js代码中,赋值的时候,这个变量成了string类型了

很明显的发现,这个ProductQty的值是string了。

function ProductQty(newValue,oldValue) {
if(newValue && oldValue && newValue != oldValue) {
var row = $('#gridlist').datagrid('getSelected');
var index = $('#gridlist').datagrid('getRowIndex',row);
row.ProductQty = newValue;
row.SalePrice = row.ProductQty * row.OriginalPrice * (row.DiscountRate / 10);
$('#gridlist').datagrid('updateRow', {index: index, row: row});
$('#gridlist').datagrid('endEdit',index);
$('#gridlist').datagrid('beginEdit',index);
countPoint();
}
}

文件里标红的部分,发现了这个row对象里的ProductQty这个值变成了string类型了。

解决办法就是给这个转成Number即可

row.ProductQty = Number(newValue);

Cannot read property 'field' of undefined (at _8 (jquery.numberbox.js:33))的更多相关文章

  1. [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法

    最近把一个项目的jQuery升级到最新版,发现有些页面报错Cannot read property ‘msie’ of undefined.上jQuery网站上搜了一下,原因是$.browser这个a ...

  2. jquery升级到新版本报错[jQuery] Cannot read property ‘msie’ of undefined错误的解决方法(转)

    最近把一个项目的jQuery升级到最新版,发现有些页面报错Cannot read property 'msie' of undefined.上jQuery网站上搜了一下,原因是$.browser这个a ...

  3. 一个关于EasyUI超恶心的BUG。。。Cannot read property 'options' of undefined

    控制台Console抛出的异常: jquery.easyui.min.js:9148 Uncaught TypeError: Cannot read property 'options' of und ...

  4. Cannot read property ‘msie’ of undefined错误原因以及解决方案

    最近把一个项目的jQuery升级到最新版,发现有些页面报错Cannot read property ‘msie’ of undefined.上jQuery网站上搜了一下,$.browser这个api从 ...

  5. [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法 --转

    初用Yii的srbac模块.出现 Cannot read property ‘msie’ of undefined 错误.上网查询,找到如下的文章.使用文末的打补丁的方法,成功搞定.感谢. ===== ...

  6. 微信小程序跳转web-vie时提示appId无法读取:Cannot read property 'appId' of undefined

    微信小程序报web-view错无法读取appId:Cannot read property 'appId' of undefined 问题描述: 我以前一直如下写代码没报错也都是可以使用的,并且小程序 ...

  7. UEditor使用报错Cannot set property 'innerHTML' of undefined

    仿用UEditor的setContent的时候报错,报错代码如下Uncaught TypeError: Cannot set property ‘innerHTML’ of undefined.调试u ...

  8. AngularJs Type error : Cannot read property 'childNodes' of undefined

    参考博客: https://blog.csdn.net/u011127019/article/details/73087868 在AngularJs和JQuery插件共存咋项目中经常会遇到如下异常 T ...

  9. Odoo14 TypeError: Cannot read property 'classList' of undefined

    Traceback: TypeError: Cannot read property 'classList' of undefined at Class.setLocalState (http://l ...

随机推荐

  1. 【活动】参加葡萄城控件主办的“谁是报表达人”知识评测活动,赢取iPad Mini2

    一.参与资格 从事报表开发的博客园用户 二.活动时间 4月1日-4月30日 三. 活动形式 在活动期间,活动参与者只要回答从题库中随机抽出的与报表相关的六道题,就可以知道自己的报表知识等级.同时活动主 ...

  2. leetcode 【 Linked List Cycle 】 python 实现

    题目: Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using ...

  3. 关于windows10设置环境变量的问题

    在设置环境变量的时候往往在网上能找到这样的文章: 1:新建环境变量 2:将新增的环境变量 加到path 变量中: 3.由于有的小伙伴的 系统是 windows10 在点击 编辑path 环境变量的时候 ...

  4. Space Shooter 太空射击

    1.控制玩家移动 public float speed = 10f; public float xMin = -6.5f; public float xMax = 6.5f; public float ...

  5. Python全栈工程师(for、列表)

    ParisGabriel     Python 入门基础         for:用来遍历可迭代对象的数据元素可迭代对象是指以此获取数据元素的对象可迭代对象包括:字符串 str 列表 list元组 t ...

  6. 孤荷凌寒自学python第三十天python的datetime.datetime模块

     孤荷凌寒自学python第三十天python的datetime.datetime模块 (完整学习过程屏幕记录视频地址在文末,手写笔记在文末) datetime.datetime模块包含了:datet ...

  7. 编译caffe遇到的问题

    1. failed to see hdf5.h https://askubuntu.com/questions/629654/building-caffe-failed-to-see-hdf5-h 2 ...

  8. jsp页面中引入java类

    <%@ page import="java.util.*" %>

  9. J2EE的十三个技术——JSP

    简介 JSP,Java Server  Page,Java服务器页面.它是在传统的网页HTML文件中插入Java程序段(Scriptlet)和JSP标记,从而形成JSP文件,后缀名为(*.jsp). ...

  10. node.js开发hello world

    在你的 D 盘下面创建一个 server.js,写入以下内容 ---------------------------------------------------- var http = requi ...