EasyUI Forum
October 03, 2025, 04:04:06 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Datagrid dynamically change background-color or image of 1 specific cell  (Read 17584 times)
can2pic
Newbie
*
Posts: 6


View Profile
« on: May 24, 2013, 09:14:14 AM »

Hi,

I need to dynamically change just 1 cells background-color within my datagrid, I have used the example below and this works.I removed the if(value) but then the entire column changed colour.

<script type="text/javascript"> 
        function cellStyler(value,row,index){ 
            if (value < 30){ 
                return 'background-color:#ffee00;color:red;'; 
            } 
        } 
    </script> 


what I am looking to do is replace my original methods:

document.getElementById('mycell1').innerHTML = "<image src='images/triangle_amber_big.png' />";

document.getElementById("mycell2").style.backgroundColor = "#f6ced8"; /*red*/

Any help appreciated,

 Thanks.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: May 25, 2013, 02:09:30 AM »

To change the cell style, a possible solution is to change the column 'styler' definition and then call 'refreshRow' method to refresh specified row.
Code:
var dg = $('#dg');
var col = dg.datagrid('getColumnOption','listprice');
col.styler = function(){
return 'background-color:#f6ced8';
};
dg.datagrid('refreshRow',index);
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!