如何为Handontable中的所有空单元格指定默认值0
How to give default value of 0 to all the empty cells in Handsontable?
我有一个简单的手控表,它从数据库中获取数据,但不是所有的单元格都有数据,有些单元格只有空值。是否可以放置一个默认值为0.00的数字格式器,而不是手动显示表中的空单元格??
这是解决方案。如果不工作,请检查并告诉我。我已经在jsfiddle上测试过了>http://jsfiddle.net/yL8t1psf/1/
$(document).ready(function () {
var container = document.getElementById('basic_example');
var data = [
['', 'Kia', 'Nissan', 'Toyota', 'Honda'],
['2014', 10, 11, 12, 13],
['2015', 20, null, , 13],
['2016', null, 15,'', null]
];
var hot = new Handsontable(container, {
data: data,
height: 396,
colHeaders: true,
rowHeaders: true,
stretchH: 'all',
columnSorting: true,
contextMenu: true,
cells: function (row, col, prop,value) {
var cellProperties = {};
cellProperties.renderer = firstRowRenderer;
return cellProperties;
}
});
});
function firstRowRenderer(instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.TextRenderer.apply(this, arguments);
if(!value || value === '' || value == null ) {
td.innerHTML = "0.00";
}
}
将其添加到条件格式中。
http://docs.handsontable.com/0.20.0/demo-conditional-formatting.html
if (!value || value === '') {
td.innerHTML = "0.00";
}
相关文章:
- 从Javascript中选定的行中获取特定单元格的值
- 无法使用document.getElementById获取动态生成的单元格的值
- Google Apps 脚本,用于根据一个单元格的值对另一个单元格进行条件颜色格式设置
- 如何循环遍历表行,更改类,并使用"n〃;行数,并知道每行中第一个单元格的值
- php脚本来增加与名称关联的单元格的值
- Asp.net 客户端单击显示表中其他单元格的值
- ExtJS 5 - 将网格中双击的单元格的值传递到新窗口
- HTML 表格单元格 - 恢复值
- 获取网格中焦点行中单元格的值
- 在 jqxGrid 中按一个单元格的值选择一行
- 我是否可以根据单元格的值使用 excel 解析某个标签的值的 html 文件
- 谷歌表格/Javascript:如何“获取单元格”动态值
- 如何在访问子网格视图时获取父网格视图的一个单元格的值
- Jquery 数据表更新单元格文本值和颜色
- 选中复选框时,有没有办法增加 HTML 表格单元格的值(仅限整数)
- 为HTML表中的单元格分配值
- 如何使用jquery从使用绝对行号的复选框中获取表单元格的值
- JointJS/Rappid更改检查器/不使用检查器的单元格模型值
- 在谷歌电子表格中,如何从另一个单元格设置单元格的值's值
- 使用JavaScript更改单元格的值