- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在调用 Handsontable
的 validateCells()
方法时收到以下错误。
我的代码:http://jsfiddle.net/o7w1ybjy/
html
<div id="example1" class="hot handsontable htColumnHeaders"></div>
</style><!-- Ugly Hack due to jsFiddle issue -->
<script src="http://docs.handsontable.com/0.16.1/scripts/jquery.min.js"></script>
<script src="http://docs.handsontable.com/0.16.1/bower_components/handsontable/dist/handsontable.full.js"></script>
<link type="text/css" rel="stylesheet" href="http://docs.handsontable.com/0.16.1/bower_components/handsontable/dist/handsontable.full.min.css">
java脚本
document.addEventListener("DOMContentLoaded", function() {
var people = [
{id: 1, name: {first: 'Joe', last: 'Fabiano'}, ip: '0.0.0.1', email: 'Joe.Fabiano@ex.com'},
{id: 2, name: {first: 'Fred', last: 'Wecler'}, ip: '0.0.0.1', email: 'Fred.Wecler@ex.com'},
{id: 3, name: {first: 'Steve', last: 'Wilson'}, ip: '0.0.0.1', email: 'Steve.Wilson@ex.com'},
{id: 4, name: {first: 'Maria', last: 'Fernandez'}, ip: '0.0.0.1', email: 'M.Fernandez@ex.com'},
{id: 5, name: {first: 'Pierre', last: 'Barbault'}, ip: '0.0.0.1', email: 'Pierre.Barbault@ex.com'},
{id: 6, name: {first: 'Nancy', last: 'Moore'}, ip: '0.0.0.1', email: 'Nancy.Moore@ex.com'},
{id: 7, name: {first: 'Barbara', last: 'MacDonald'}, ip: '0.0.0.1', email: 'B.MacDonald@ex.com'},
{id: 8, name: {first: 'Wilma', last: 'Williams'}, ip: '0.0.0.1', email: 'Wilma.Williams@ex.com'},
{id: 9, name: {first: 'Sasha', last: 'Silver'}, ip: '0.0.0.1', email: 'Sasha.Silver@ex.com'},
{id: 10, name: {first: 'Don', last: 'Pérignon'}, ip: '0.0.0.1', email: 'Don.Pérignon@ex.com'},
{id: 11, name: {first: 'Aaron', last: 'Kinley'}, ip: '0.0.0.1', email: 'Aaron.Kinley@ex.com'}
],
example1 = document.getElementById('example1'),
example1console = document.getElementById('example1console'),
settings1,
ipValidatorRegexp,
emailValidator;
ipValidatorRegexp = /^(?:\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b|null)$/;
emailValidator = function (value, callback) {
setTimeout(function(){
if (/.+@.+/.test(value)) {
callback(true);
}
else {
callback(false);
}
}, 1000);
};
settings1 = {
data: people,
beforeChange: function (changes, source) {
for (var i = changes.length - 1; i >= 0; i--) {
// gently don't accept the word "foo" (remove the change at index i)
if (changes[i][3] === 'foo') {
changes.splice(i, 1);
}
// if any of pasted cells contains the word "nuke", reject the whole paste
else if (changes[i][3] === 'nuke') {
return false;
}
// capitalise first letter in column 1 and 2
else if ((changes[i][1] === 'name.first' || changes[i][1] === 'name.last') && changes[i][3].charAt(0)) {
changes[i][3] = changes[i][3].charAt(0).toUpperCase() + changes[i][3].slice(1);
}
}
},
afterChange: function (changes, source) {
if (source !== 'loadData') {
example1console.innerText = JSON.stringify(changes);
}
},
colHeaders: ['ID', 'First name', 'Last name', 'IP', 'E-mail'],
columns: [
{data: 'id', type: 'numeric'},
{data: 'name.first'},
{data: 'name.last'},
{data: 'ip', validator: ipValidatorRegexp, allowInvalid: true},
{data: 'email', validator: emailValidator, allowInvalid: true}
]
};
var hot = new Handsontable(example1, settings1);
function bindDumpButton() {
if (typeof Handsontable === "undefined") {
return;
}
Handsontable.Dom.addEvent(document.body, 'click', function (e) {
var element = e.target || e.srcElement;
if (element.nodeName == "BUTTON" && element.name == 'dump') {
var name = element.getAttribute('data-dump');
var instance = element.getAttribute('data-instance');
var hot = window[instance];
console.log('data of ' + name, hot.getData());
}
});
}
bindDumpButton();
hot.validateCells();
});
Uncaught TypeError: undefined is not a function handsontable.full.js:4279ValidatorsQueue.checkIfQueueIsEmpty handsontable.full.js:4279ValidatorsQueue.removeValidatorFormQueue handsontable.full.js:4273(anonymous function) handsontable.full.js:4814done handsontable.full.js:4383(anonymous function) handsontable.full.js:4398(anonymous function)
最佳答案
您在没有回调的情况下调用 hot.validateCells() ,这导致了问题。
检查handsontable.full.js中的以下方法:
function ValidatorsQueue() {.....}
this.validateCells = function(callback) {....}
可能与此问题相关:https://github.com/handsontable/handsontable/issues/933
关于javascript - 获取类型错误 : undefined is not a function on handsontable. validateCells(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31742119/
如何使用 handsontable 中的 handsontable 禁用特定列。我希望第一列仅可编辑,其他三列被禁用。我对三列使用 readonly true 但如何禁用它不起作用....
如何使用 handsontable 中的 handsontable 禁用特定列。我希望第一列仅可编辑,其他三列被禁用。我对三列使用 readonly true 但如何禁用它不起作用....
似乎是一项简单的任务,但我还没有找到简单的解决方案。我的数据有时以空数组的形式出现,以便用户可以开始处理空表(标题除外)。该表有一个 minSpareRows:1所以我希望表格会出现那个备用行而不是其
问题 :我可以更改单元格的背景颜色,但不能更改标题的背景颜色。我可以在 Handsontable 中更改标题的背景颜色和字体颜色吗? 最佳答案 您可以为此使用 jquery 或 css。例如,将背景颜
客户 ID 列设置为使用自动完成。自动完成值将各种客户信息连接在一起,以帮助用户选择正确的信息。选择后,客户 ID 将放入网格中。 我无法弄清楚如何使自动完成弹出窗口更宽,以便它适合连接的信息。 这就
在 Handsontable 中,当单击列标题时,将选择该列的所有单元格。有办法防止这种情况发生吗? 我认为文档中没有这样的选项。我也没有在 Handsontable 库本身的源代码中找到事件在 DO
我正在尝试像这样更新 Handsontable 中的列设置: var newColumnSettings = [{ data: 0, readOnly: true }, { data: 1 }, {
我可以看到有一些方法可以在渲染前在单元格数组中创建注释,并使用上下文菜单。但是有没有办法在更改后创建评论? 我最初试过这个: var errors = []; var hot = new Handso
如何在此下拉菜单中允许固定高度? (柱车) 我一直在无休止地摆弄以解决高度问题。我想要一个最大 300px 的固定高度下拉菜单。我用过AutoRowSize handsontable 站点中的高度功能
我正在尝试在 Handsontable 网格内使用“Handsontable”编辑器。我希望用户能够从“下拉”类型菜单中进行选择,但该菜单显示多列相关数据(用户正在选择一个 ID 号,我希望能够显示相
我正在尝试使用 Handsontable 版本 0.34.4CE/1.14.2 PRO 在 Handsontable (HOT-in-HOT) 中创建 Handsontable。根据此处提供的文档,一
有没有什么方法可以从列名中获取列号? 我只能检索列名,我需要 getCellMeta 的列号。 谢谢 最佳答案 使这个功能解决了我的问题: function GetColFromName(name)
我正在尝试将handsontable下拉列表的宽度设置为根据查找数据宽度,而不是列宽。如何做到这一点? 请看下图。下拉列表太窄,无法容纳查找数据。 最佳答案 https://github.com/ha
我希望能够在Handsontable中编辑列标题的文本,但似乎无法弄清楚是否可以使它们可编辑。我想我可以将标题改成另一行,但我想尽可能避免这种情况。 澄清一下:我实际上是在寻找一种允许用户编辑 hea
是否可以在事件内部更改 Handsontable 实例中的源? 下面是我的代码: var container2 = $('#example2'); var hot2 = new Handsontabl
HandsonTable 不会渲染所有行 - 它仅加载所有行的一部分。但是,当我执行 Ctrl+A 并将其粘贴到 Excel 中时,我会看到所有行。为什么 Handsontable 不显示所有行?
我正在尝试动态地将一列添加到手动表中。我在任何地方都没有看到示例,也没有在 API 中看到这样做的方法。有没有人找到一种方法来克服这个问题,或者有一些示例代码可供我查看,这会有所帮助。 谢谢。 最佳答
是否可以让 Handsontable 中的数据按未显示的字段排序?我有一个数据网格,我想显示它包含一个名为“sortOrder”的列,但我不想显示它。 排序需要在客户端完成,因为事件是通过网络套接字传
我正在使用 handsontable,我的代码是用 typescript/aurelia 编写的。我无法将复选框列居中对齐。我关注了this链接并将我的复选框列上的 className 设置为“htC
是否可以设置 max-width和 max-height对于 Handsontable 中的单元格? 我试图通过 CSS 在 上进行设置和 元素,但这不起作用。 我在文档中看到您可以将列设置为特定宽
我是一名优秀的程序员,十分优秀!