1

いくつかのonChangeイベントを処理し、うまく機能する関数があります。その関数は別の関数を呼び出してセルの内容をチェックし、何か問題がある場合はセルの色を変更する必要があります。

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 があります:

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 が呼び出されることはありません。

ありがとうございました

4

2 に答える 2

1

handontable を使用している場合は、その組み込み機能を使用してみませんか?

HT の条件付き書式設定を見てください。

また、バージョン 0.9.5 では列オプションが追加されましvalidatorた。詳細はこちら

validator (value: Mixed, callback: Function) 

また

validator : RegExp Object

次に、イベントを使用します (詳細はこちら):

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

セルの書式設定を行います

また、あなたの例ではレンダラーを設定していますが、セルは実際にレンダリングされていますか? 再レンダリングする必要がありますか?

于 2013-07-22T00:19:20.390 に答える