我正在寻找一种在下拉列表中显示数值 0 的方法,该下拉列表还包括单元格为空时的占位符文本。目前,如果选择 0,则占位符文本会显示出来。我希望有一个内置选项,如果可以的话,我想避免将数字转换为字符串并返回(这会破坏我当前的验证方案)。以下示例是根据 HandsOnTable 下拉文档修改的。“机箱颜色”列包含问题。
jsfiddle: https ://jsfiddle.net/y3pL0vjq/
片段:
function getCarData() {
return [
["Tesla", 2017, "black", "black"],
["Nissan", 2018, "blue", "blue"],
["Chrysler", 2019, "yellow", "black"],
["Volvo", 2020, "white", "gray"]
];
}
var
container = document.getElementById('example1'),
hot;
hot = new Handsontable(container, {
data: getCarData(),
colHeaders: ['Car', 'Year', 'Chassis color', 'Bumper color'],
columns: [
{},
{type: 'numeric'},
{
type: 'dropdown',
placeholder: "blah",
source: [null, 0, 1, 2, 3]
},
{
type: 'dropdown',
source: ['yellow', 'red', 'orange', 'green', 'blue', 'gray', 'black', 'white']
}
]
});