2013-07-18 3 views
1

일부 onChange 이벤트를 처리하는 함수가 있습니다. 이 함수는 셀의 내용을 확인하기 위해 다른 함수를 호출합니다. 잘못된 것이 있으면 셀의 색이 바뀌어야합니다. 경고가, 어떤 생각이 왜 트리거 있는데도,handsontable plugin에서 사용자 정의 렌더러 함수가 작동하지 않습니다.

function ErrorRenderer(instance, td, row, col, prop, value, cellProperties) 
{ 
    Handsontable.TextCell.renderer.apply(this, arguments); 
    console.log(row); 
    td.style.fontWeight = 'bold'; 
    td.style.color = 'green'; 
    td.style.background = '#CEC'; 
} 

ErrorRenderer가 호출되지 않습니다 :

function Check(x, y) 
{ 
    var content = $editorTableContainer.handsontable('getDataAtCell', y, x); 
    var split = content.split(' ');  

    $.each(split, function (key, value) { 
     $.get('check.php?word=' + value, function (data) { 
      //blank if no error otherwise it returns an array of suggestions (only need to check if there is an error) 
      if (data) { 
       alert("test"); 
       var meta = $editorTableContainer.handsontable('getCellMeta', y, x); 
       meta.renderer = ErrorRenderer; 
      } 
     }); 
    }); 

    return; 
} 

그리고 여기 내 간단한 ErrorRenderer입니까? 당신이 handsontable를 사용하는 경우

, 왜 당신은 그것의 기능 내장 사용하지 않는 당신에게

+1

오프 주제 확인할 수 있습니다 FWIW, 예약에 유용한 JS 코드 컨벤션있다 생성자 함수에 대해서만 대문자로 된 함수 이름. http://javascript.crockford.com/code.html#names – alxndr

+0

감사합니다. 나는 그 것을 알지 못했다. – Cornwell

+0

아래의 대답에 대한 렌더링에 대한 의견보기 – PostureOfLearning

답변

1

감사?

는 열 옵션 validator을 추가 한 버전 0.9.5에서, HTS 또한

conditional formatting에서보세요. 세부 사항 here.

validator (value: Mixed, callback: Function) 

또는 그런 경우 (자세한 here)를 사용하여

validator : RegExp Object 

:

afterValidate (isValid: Boolean, value: Mixed, row: Number, prop: String, source: String) 

이 예에서,

또한 셀의 서식을을, 당신은 설정하는 렌더러가 실제로 렌더링되는 셀입니까? 다시 렌더링해야합니까?

0

나는, 단지 텍스트 셀에 대해 작동합니다 .. 여러분의 렌더러가 TextCell에 대한 것을 볼 그 오류 렌더러가 TextCell을 위해 일한다 또는 NumericCell