EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: kavvson on September 20, 2014, 09:10:58 AM



Title: rowStyler change background if equal to text
Post by: kavvson 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?


Title: Re: rowStyler change background if equal to text
Post by: stworthy 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;...';
}
}
})