2017-03-08 161 views
0

関数を使用してHandsOnTableセルの背景を変更すると、セルにレンダリングされた値が小数点以下1桁に変更されます。私は誤って書式文字列を削除したためだと思いましたが、それは間違っているようです。レンダラーを使用するとHandsOnTableセルの値が変化する

これは、レンダラ、細胞機能および列の定義である:

function negativeValueRenderer(instance, td, row, col, prop, value, cellProperties) { 
    Handsontable.renderers.TextRenderer.apply(this, arguments); 

    if (value !== instance.getData()[row][2]) 
     td.style.background = 'yellow'; 
} 
Handsontable.renderers.registerRenderer('negativeValueRenderer', negativeValueRenderer); 

function cells(row, col, prop) { 
    if (col === 1) 
     return { format: '0.00', renderer: negativeValueRenderer } 
    else 
     return { format: '0.00', } 
} 

var colDefs = [ 
    { 
     dateFormat: 'DD/MM/YYYY HH:mm', 
     correctFormat: true, 
     width: 150, 
     editor: false, 
     disableVisualSelection: true, 
     readOnly: true, 
    }, { 
     type: 'numeric', 
     format: '0.00', 
     width: 75 
    }, { 
     type: 'numeric', 
     format: '0.00', 
     width: 75, 
     editor: false, 
     readOnly: true, 
    } 
]; 

は、どのように私は持っている細胞、例えば、1254.23で小数第2位を維持していることを確認することができます - 私のテーブルには3列目は2でレンダリングされます小数点以下桁数は1桁です。

答えて

0

私は同様の問題がありました。 同じページには2つのハンドアウトがあり、両方でアクティブな行の色を付ける必要がありました。

Handsontable.renderers.TextRenderer.apply(this, arguments); 

、その行は私のようにチェックボックスがあり、行、数字、ドロップダウンとでの問題の多くをもたらします:だから私はラインを持っているリンクhttps://docs.handsontable.com/0.31.1/demo-conditional-formatting.html

からの例に従ってください。私は間違っているかもしれないが、私が理解できるところでは、何かをテキストに変換することは理解できる。問題のトラックで問題を解決しましたhttps://github.com/handsontable/handsontable/issues/732

すべてのセルには独自のタイプがあり、タイプによっては異なるタイプのレンダラーが適用されていることがわかります。

 case 'text': 
      Handsontable.TextCell.renderer.apply(this, arguments); 
      break; 
     case 'autocomplete': 
      Handsontable.AutocompleteCell.renderer.apply(this, arguments); 
      break; 
     case 'checkbox': 
      Handsontable.CheckboxCell.renderer.apply(this, arguments); 
      break; 
     case 'numeric': 
      Handsontable.NumericCell.renderer.apply(this, arguments); 
      break; 
     case 'date': 
      Handsontable.DateCell.renderer.apply(this, arguments); 
      break; 
     case 'handsontable': 
      Handsontable.HandsontableCell.renderer.apply(this, arguments); 
      break; 
     default: 
      Handsontable.TextCell.renderer.apply(this, arguments); 
      break; 

あなたのcolDefからは、column-cellのタイプが得られます。 それがあなたを助けることを願っています。

幸運

関連する問題