2013-08-09 1 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}] 
}); 

이것은 기본적는 세포와 속성에 추가 클래스와 숫자 유형의 확장자 것이다 : 좋아 호출 할 수 있도록 나는 handsontable에 대한 사용자 정의 셀 유형을 만들고 싶어. 는 그러나 그 순간에 나는 오류 :

+0

그리고이었다

renderer: Handsontable.NumericRenderer2, 

에 있었다 : "형식 오류 방법은없는 기능입니다" 무엇을 도와 드릴까요? – michaelward82

+0

코드가 업데이트되었는데 왜 오류가 발생합니까? – ailmcm

답변

1

죄송합니다 귀찮게하는 사람 ( 유일한 문제는 대신

renderer: Handsontable.AttestationRenderer,