DATA Table ... How to change the Color of cell as per the Cell Value Of Table

AKVYAS23

I am using Datatable Concept but don't know how to change the the color of a cell as per the cell value. I know How to change the entire row's color as per the cell value .. Here is the code which I am using for row .. Where should I change the code ...??

$('#example').DataTable( {
                //"bDestroy": true, // NOT Working THis Function Here ...!!! 
                dom: 'Bfrtip',
                buttons: ['copy', 'csv', 'excel', 'pdf', 'print'],
                retrieve: true,
                //FOR COLOR CODING AS PER THE VALUES in THe ROW/ CELL..!!!-NOW IT is for the Entire Row .. !!
                "fnRowCallback": function( nRow, myInfraArray)
                {
                            if ( myInfraArray[3] == "" )
                            {
                                $('td', nRow).css('background-color', '#F08080');
                            }
                            else if ( myInfraArray[3] == "Not Availiable" )
                            {
                                $('td', nRow).css('background-color', '#F08080');
                            }
                            else if ( myInfraArray[3] >= 5 && myInfraArray[3] <= 15)
                            {
                                $('td', nRow).css('background-color', '#90EE90');
                            }
                            else if (myInfraArray[3] >= 0 && myInfraArray[3] <= 4 )
                            {
                                $('td', nRow).css('background-color', '#FFDAB9');
                            }

                        }
                    } );
AKVYAS23

I have solved IT ... :) Here Is the Code For change the color of a cell as per the cell value...

     $('#example').DataTable( {
                        //"bDestroy": true, // NOT Working THis Function Here ...!!! 
                        dom: 'Bfrtip',
                        buttons: ['copy', 'csv', 'excel', 'pdf', 'print'],
                        retrieve: true,
                        //FOR COLOR CODING AS PER THE VALUES in THe ROW/ CELL..!!!-NOW IT is for the Entire Row .. !!
                        "fnRowCallback": function( nRow, myInfraArray)
                        {
                                      $(nRow).children().each(function(index, td, myInfraArray) {     
                                        if ($(td).html() == "") {
                                              $(td).css("background-color", "#F08080");
                                           } else if ($(td).html() == "Not Available") {
                                              $(td).css("background-color", "#F08080");
                                           } else if (($(td).html() >= 5 && $(td).html() <= 20)) 
{  $(td).css("background-color", "#90EE90");
                                           } else if (($(td).html() >= 00 && $(td).html() <= 4) || ($(td).html()=="not working"))
     $(td).css("background-color", "#FF3229");
                                    $('table:last tr:nth-child(2) td:nth-child(2)').
                                    css("background-color", "#cccccc");
                                } );
                                return nRow;
                                }
                            } );

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How change cell table color in php based on cell value?

From Dev

How change cell table color in php based on cell value?

From Dev

how to change the table cell color using jquery

From Dev

Using javascript to change table cell background color based on json value

From Dev

Change table cell color depending on value in asp and C#

From Dev

How to table cell value font color change VBA word? Font.Textcolor not working why?

From Dev

Angular: How to change the color of cell table if condition is true

From Dev

How to change the background color of selected expandable table view cell

From Dev

How to change the color of a table cell by the index of row and column?

From Dev

Cannot change color in cell of table in html

From Dev

Change the color of UILabel inside table cell when cell is tapped

From Dev

Change the color of UILabel inside table cell when cell is tapped

From Dev

Color scale to the table cells according to cell value

From Dev

How to change cell value of an html table through javascript

From Dev

How do I change the value of a cell based on the position of a team in a table?

From Dev

Tick a checkbox in a table cell by clicking anywhere in the table cell and change background color of that cell

From Dev

Tick a checkbox in a table cell by clicking anywhere in the table cell and change background color of that cell

From Dev

Dynamically change value of a <select> inside cell of a table

From Dev

Detect html table cell value change

From Dev

AngularJS: Change cell class in a dynamically generated table based on cell value

From Dev

Jquery change table cell value if other cell contains word

From Dev

How to force the border color of a cell in a html table

From Dev

How to Set the Background Color of a Cell in a MigraDoc Table

From Dev

how to remove the table cell separator with a background color

From Dev

How to change DataGrid cell background color based on cell value

From Dev

How to change background color of cell based on other cell value by VBA

From Dev

How do I change the value in an Excel table cell without specifying a cell reference in VBA

From Dev

How do I change the value in an Excel table cell without specifying a cell reference in VBA

From Dev

How to change the css style and link of a previous table cell based on current cell value in jQuery

Related Related

  1. 1

    How change cell table color in php based on cell value?

  2. 2

    How change cell table color in php based on cell value?

  3. 3

    how to change the table cell color using jquery

  4. 4

    Using javascript to change table cell background color based on json value

  5. 5

    Change table cell color depending on value in asp and C#

  6. 6

    How to table cell value font color change VBA word? Font.Textcolor not working why?

  7. 7

    Angular: How to change the color of cell table if condition is true

  8. 8

    How to change the background color of selected expandable table view cell

  9. 9

    How to change the color of a table cell by the index of row and column?

  10. 10

    Cannot change color in cell of table in html

  11. 11

    Change the color of UILabel inside table cell when cell is tapped

  12. 12

    Change the color of UILabel inside table cell when cell is tapped

  13. 13

    Color scale to the table cells according to cell value

  14. 14

    How to change cell value of an html table through javascript

  15. 15

    How do I change the value of a cell based on the position of a team in a table?

  16. 16

    Tick a checkbox in a table cell by clicking anywhere in the table cell and change background color of that cell

  17. 17

    Tick a checkbox in a table cell by clicking anywhere in the table cell and change background color of that cell

  18. 18

    Dynamically change value of a <select> inside cell of a table

  19. 19

    Detect html table cell value change

  20. 20

    AngularJS: Change cell class in a dynamically generated table based on cell value

  21. 21

    Jquery change table cell value if other cell contains word

  22. 22

    How to force the border color of a cell in a html table

  23. 23

    How to Set the Background Color of a Cell in a MigraDoc Table

  24. 24

    how to remove the table cell separator with a background color

  25. 25

    How to change DataGrid cell background color based on cell value

  26. 26

    How to change background color of cell based on other cell value by VBA

  27. 27

    How do I change the value in an Excel table cell without specifying a cell reference in VBA

  28. 28

    How do I change the value in an Excel table cell without specifying a cell reference in VBA

  29. 29

    How to change the css style and link of a previous table cell based on current cell value in jQuery

HotTag

Archive