2013-08-09 3 views
1

Добрый день, каждый. Я хочу сделать пользовательский тип клеток для 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}] 
}); 

Basicaly это Удлинитель бы для числового типа с дополнительными классами для клеток и атрибутов. Но в данный момент я получаю сообщение об ошибке: «Ошибка типа: метод не является функцией»

+0

И Что бы вы хотели помочь? – michaelward82

+0

обновленный код, я не понимаю, почему я получил ошибку .. – ailmcm

ответ

1

К сожалению беспокоят ребята ( Единственная проблема была в

renderer: Handsontable.NumericRenderer2, 

, который был вместо

renderer: Handsontable.AttestationRenderer, 
Смежные вопросы