Pentaho

 View Only

 CDE Table component - Conditional color of row

  • Pentaho
  • Community Dashboard Editor CDE
  • Kettle
  • Pentaho
  • Pentaho Data Integration PDI
Data Conversion's profile image
Data Conversion posted 03-05-2018 13:08

Hello,

I need to change the color of row due to value in a cell.

I think it is possible with js code (AddIns options).

Can anyone help me?


#Kettle
#CommunityDashboardEditorCDE
#Pentaho
#PentahoDataIntegrationPDI
Data Conversion's profile image
Data Conversion

Below my solution (table 3x3) - Pre-Execution code:

function f(){ 

    this.setAddInOptions("colType","formattedText",function(state){

        if(state.colIdx === 0)

        {

            var type = state.tableData[state.rowIdx][2];

            if(type == 76){

                    return {  textFormat: function(v, st) { return "<div style='background:red;'>"+v+"</div>"; } };

                 }   

        }

        if(state.colIdx === 1)

        {

            var type2 = state.tableData[state.rowIdx][2];

            if(type2 == 76){

                    return {  textFormat: function(v, st) { return "<div style='background:red;'>"+v+"</div>"; } };

             }      

        }

         if(state.colIdx === 2)

        {

            var type3 = state.tableData[state.rowIdx][2];

            if(type3 == 76){

                    return {  textFormat: function(v, st) { return "<div style='background:red;'>"+v+"</div>"; } };

             }      

        }

      });

}

Regards

Ema

Harshit Agrawal's profile image
Harshit Agrawal

Hi Ema,

I tried it but it seems not to be working.

Is there anything else needs to be done apart from adding above in Pre Execution.

e.g. - Not sure what is state in the above function. Is this name of your table.

Paulo Pires's profile image
Paulo Pires

HI Harshit,

Make sure you didn't forget to set the column types of the table as formattedText.

Best regards