簡體   English   中英

關於Handsontable條件格式

[英]regarding Handsontable conditional Formatting

我有一個包含值的Handsontable,我需要應用數字格式,例如$0,0.00 使用下面的代碼我可以實現它,但是如果我將renderer應用於cellproperty,則通過覆蓋以前的單元格格式,單元格將以新樣式更改。請告訴我我在做什么錯誤

function inHeadRenderer(instance, td, row, col, prop, value, cellProperties) {
        Handsontable.TextCell.renderer.apply(this, arguments);
         td.style.textAlign="left"
         td.style.paddingLeft="1%";
         td.style.fontWeight = 'bold';
         td.style.fontSize="10px";
         td.style.fontFamily= 'verdana';
         td.style.background = '#FCFFFA';
         td.style.color = '#0B610B';
    }



cells: function (row, col, prop) {
if($("#handsontable").handsontable('getData')[col,row][num_cols-1] ==="Inflow"){
             cellProperties={
                       type: 'numeric', 
                       format:'0,0.00',
                       language: 'en'


                }

  return cellProperties;
}

我想為已格式化的單元格Properites應用樣式

每次對單元格進行更改時,都會觸發渲染器。 這就是重寫格式的原因。

更新資料

http://jsfiddle.net/hU6Kz/3519/是可供參考的工作代碼。

更正。 包含在渲染器中的類型

inHeadRenderer=function(instance, td, row, col, prop, value, cellProperties) {
   Handsontable.NumericCell.renderer.apply(this, arguments);
     td.style.textAlign="left"
     td.style.paddingLeft="1%";
     td.style.fontWeight = 'bold';
     td.style.fontSize="10px";
     td.style.fontFamily= 'verdana';
     td.style.background = '#FCFFFA';
     td.style.color = '#0B610B';
    cellProperties.type = 'numeric';
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM