首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >可处理的自定义单元格类型

可处理的自定义单元格类型
EN

Stack Overflow用户
提问于 2013-08-09 13:55:39
回答 1查看 4.9K关注 0票数 1

大家好。我想为handsontable定制单元格类型,这样就可以像这样调用它:

代码语言:javascript
复制
//custom renderer
Handsontable.AttestationRenderer = function (instance, TD, row, col, prop, value, cellProperties) {
  if (Handsontable.helper.isNumeric(value)) {
    if (typeof cellProperties.language !== 'undefined') {
      numeral.language(cellProperties.language)
    }
    value = numeral(value).format(cellProperties.format || '0'); //docs: http://numeraljs.com/
    instance.view.wt.wtDom.addClass(TD, 'htNumeric');
  }
  td.addClass('attestationCell');
  Handsontable.TextRenderer(instance, TD, row, col, prop, value, cellProperties);
};  

//custom cell
Handsontable.AttestationCell = {
  editor: Handsontable.TextEditor,
  renderer: Handsontable.NumericRenderer2,
  validator: Handsontable.NumericValidator,
  dataType: 'number'
};

//here setup the friendly aliases that are used by cellProperties.type
Handsontable.cellTypes = {
  text: Handsontable.TextCell,
  date: Handsontable.DateCell,
  numeric: Handsontable.NumericCell,
  attestation: Handsontable.AttestationCell,
  checkbox: Handsontable.CheckboxCell,
  autocomplete: Handsontable.AutocompleteCell,
  handsontable: Handsontable.HandsontableCell
};

var hotcontainer = $('#example');

hotcontainer.handsontable({
columns: [
        {data : "id", type : "numeric"}
        ,{data : "att", type : "attestation"}
    ]
,data : [{id:1, att : 10},{id:10, att:100}]
});

基本上,它将扩展到数值类型,增加了对单元格和属性的类。但是现在我得到了错误:"TypeError: method不是一个函数“

EN

回答 1

Stack Overflow用户

发布于 2013-08-09 19:31:10

抱歉打扰你们了(唯一的问题是

代码语言:javascript
复制
renderer: Handsontable.NumericRenderer2,

而不是

代码语言:javascript
复制
renderer: Handsontable.AttestationRenderer,
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18140791

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档