dhtmlxGrid Cell.getValue()获取带&字符数据问题
来源:互联网 发布:乌玛·瑟曼 知乎 编辑:程序博客网 时间:2024/06/16 13:29
在项目中使用到 dhtmlxGrid 作为表格数据的展示。
其中删除功能对图中标注的数据不能进行正常删除操作,而其他数据却能正常删除。
删除语句如下:
delete from pub_txxxx where report_code_1 = @report_code_1 and report_code_2 = @report_code_2。
图一:数据库存储数据
图二:web界面展示的数据
Sql语句简单,不会出错。
那问题可定出在界面展示的数据传递到后台时反生了改变。来看一下Jquery 是怎么获取这一行这两列的数据值的。
//点击删除按钮,selectedId 定位到数据的行, colIndex定位到数据列
if(type=="coro") { value = grid.cellById(selectedId, colIndex).cell.combo_value;
}
else{
value = grid.cellById(selectedId, colIndex).getValue();
// 获得值
if(type=="rd"){ var rg = /-/gi; value = value.replace(rg,""); }
}
再来看一下传入后台是什么数据:
后台的数据也变成了m1609&a1605。那这就是可以明确字符串中的&字符影响了取值结果。
value = grid.cellById(selectedId, colIndex).getValue();// 获得值
再来看一下.getValue()是怎么取值的。
getValue()源码如下:
1 function () {
2 return this.cell.firstChild && this.cell.atag && this.cell.firstChild.tagName
3 == this.cell.atag ? this.cell.firstChild.value : this.cell._clearCell ?
4 "" : this.cell.innerHTML.toString()._dhx_trim()}
可以看到,最终返回的是cell.innerHTML 属性的值,也就是 m1701&m1605。所以,只需要改成取cell.innerText 属性值就可。
最终代码改为如下:
value = grid.cellById(selectedId, colIndex).innerText.toString();// 获得值
- dhtmlxGrid Cell.getValue()获取带&字符数据问题
- dhtmlxgrid 自定义单元格 edit getValue setValue 事件
- dhtmlxGrid加载数据
- dhtmlx使用翻译(三)dhtmlxgrid 数据加载部分
- dhtmlxgrid 使用json数据 入门
- JS-封装函数getValue(key),实现获取请求数据中的value值
- Jxl 中Cell获取到的excel数据保留精度问题
- dhtmlx使用翻译(八)dhtmlxgrid 保存数据操作 使用后记
- dhtmlxgrid实现左右列表数据移动
- dhtmlxGrid初始化加载,jquery请求加载数据
- ExtJS4 中 setValue和getValue 的问题
- 记:combotree中getValue和getText问题
- UITableView获取cell的row值(解决自定义cell里的button通过点击无法获得cell的indexpath的问题)
- UITableView获取cell的row值(解决自定义cell里的button通过点击无法获得cell的indexpath的问题)
- WPF 依赖属性,用户控件依赖属性(DependencyProperty 依赖属性、GetValue() SetValue() CLR属性包装器、SetBinding 数据绑定)
- cell 复用问题 cell中控件单选,多选,带标签图的不可选中
- 获取combobox的displayfield和valuefield字段值 getValue()
- ThinkPHP获取带条件数据总条数(行数)
- Yarn的JVM重用功能——uber
- 显著性检测(二)Spatio-temporal Saliency Detection Using Phase Spectrum of Quaternion Fourier Transform
- PC制做gif动图超简单教程
- 二叉树的遍历(递归、非递归)
- Linux中的crontab详解
- dhtmlxGrid Cell.getValue()获取带&字符数据问题
- [BZOJ1003][ZJOI2006]物流运输(最短路+dp)
- 机器学习实战【7】(SMO算法实现)
- hihocoder #1584 : Bounce(规律)
- set、env、export——Linux中的环境变量命令
- Spring学习笔记(五) --- 装配Bean之导入和混合配置
- Minimum (ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 题9)
- Oracle 小记
- Java Calendar 类的时间操作