我正在尝试使用handsontable为我的用户构建一个编辑器,以便将数据添加到我的数据库中。
我有以下HTML文件:
<html>
<head>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/handsontable/0.35.0/handsontable.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/handsontable/0.35.0/handsontable.min.css" rel="stylesheet">
</head>
<body>
<div style='height:100px; width:100px; background-color: black' id='hello'></div>
<script type="text/javascript" src="stuff.js"></script>
</body>
</html>
和stuff.js
let colNames = ['adwords_id', 'status', 'client', 'is_unlimited', 'account_budget',
'remaining_account_budget', 'currency', 'exchange_rate', 'vendor', 'batch',
'vps', 'login', 'password', 'external_comment', 'internal_comment']
hot = new Handsontable(document.getElementById('hello'), {
startRows:8,
startCols: colNames.length,
rowHeaders: true,
colHeaders: colNames,
columns: [
{ allowEmpty: false },
{ type:'dropdown', source: ['active', 'dead'] },
{ type:'dropdown', source: ['bart', 'alex'] },
{ type:'checkbox' },
{ type:'numeric', // TODO undefined "culture"
numericFormat: { pattern: '$0,0.00', culture: 'en-US' },
},
{},
{ type:'dropdown', source: ['usd', 'hkd'] },
{},
{ type:'dropdown', source: ['acme inc', 'hong kong company'] },
{},
{ type:'dropdown', source: ['hk-001', 'hk-002'] },
{},
{},
{},
{},
]
});
当我尝试编辑“account_budget”列时,我收到以下错误:
handsontable.min.js:29 Uncaught TypeError: Cannot read property 'culture' of undefined
at i (handsontable.min.js:29)
at i.setDataAtCell (handsontable.min.js:29)
at Object.populateFromArray (handsontable.min.js:29)
at i.populateFromArray (handsontable.min.js:29)
at t.n.saveValue (handsontable.min.js:29)
at t.n.finishEditing (handsontable.min.js:29)
at n.closeEditor (handsontable.min.js:29)
at n.closeEditorAndSaveChanges (handsontable.min.js:29)
at i.p (handsontable.min.js:29)
at e.value (handsontable.min.js:29)
我关闭了数字,这个错误消失了。
有什么想法吗?
答案 0 :(得分:0)
这有效:
{
data: 'price_usd',
type: 'numeric',
format: '$0,0.00',
language: 'en-US' // this is the default locale, set up for USD
},
{
data: 'price_eur',
type: 'numeric',
format: '0,0.00 $',
language: 'de-DE'
}