【问题标题】:Handsontable custom cell typeHandsontable 自定义单元类型
【发布时间】:2013-08-11 00:54:02
【问题描述】:

大家好。我想为handsontable制作自定义单元格类型,以便可以这样称呼它:

//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:方法不是函数”

【问题讨论】:

  • 您需要什么帮助?
  • 更新了代码,我不明白为什么会出错..

标签: jquery handsontable


【解决方案1】:

打扰各位了( 唯一的问题是在

renderer: Handsontable.NumericRenderer2,

那不是

renderer: Handsontable.AttestationRenderer,

【讨论】:

    猜你喜欢
    • 2015-10-18
    • 2015-01-01
    • 1970-01-01
    • 2013-09-02
    • 1970-01-01
    • 2014-09-06
    • 2016-04-26
    • 2015-09-14
    • 1970-01-01
    相关资源
    最近更新 更多