EasyUI Forum
September 13, 2025, 02:13:41 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: rowStyler change background if equal to text  (Read 7027 times)
kavvson
Newbie
*
Posts: 23


View Profile
« on: September 20, 2014, 09:10:58 AM »

Code:
if (row.return == "Not Returned"){
return 'background-color:orange;color:blue;font-weight:bold;';
}

The thing is I paste from my php file a number 0,1,2 or I can type a string but when I would like to paste the numbers only I will need to transform them to text

Code:
----------+--------------------
| Status  |   Other Columns
----------+--------------------
|    0      | { other data }
|    2      | { other data }
|    0      | { other data }
......etc

transform to
Code:
----------+--------------------
| Status  |   Other Columns
----------+--------------------
|    Not returned       | { other data }
|         Returned       | { other data }
|    Not returned       | { other data }
Additionally with the possibility to change background color for each Status.

Any tips?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: September 21, 2014, 05:02:34 PM »

Use the column's formatter function and you will be able to define the displaying value for a specified column. Please refer to the code below:
Code:
$('#dg').datagrid({
columns:[[
{field:'status',title:'Status',width:100,formatter:function(value,row){
if (value == 0){
return 'Not returned';
} else if (value == 2){
return 'Returned';
} else {
//...
}
}}
]],
rowStyler:function(index,row){
if (row.return == 'Not Returned'){
return 'background-color:orange;...';
}
}
})
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!