EasyUI Forum
May 06, 2024, 10:31:49 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: Does formatter:function cancel out styler:function?  (Read 7302 times)
swells808
Newbie
*
Posts: 15


View Profile
« on: October 07, 2014, 03:21:30 PM »

I have one column of my data grid that needs to do 2 different things
1. I need to subtract the entries from 2 different columns to return the result to this column (col a - col b = col c)
2. I need to set conditional styling for this column so if the result is >10 its turns yellow but if its >5 it turns red.

So here is the code I added to my grid, the problem I am having is the math result comes through correctly but the cell styler is ignored entirely (prior to the math function the styler would ignore the else statement). It seems like I can only call for one function to be completed which can't be right can it? Here is my code:

Code:
<table id="dg" title="Maintenance Log" class="easyui-datagrid" style="width:1000px;height:650px"
url="get_users.php"
toolbar="#toolbar"
data-options="
pagination:true,
rownumbers:true,
fitColumns:true,
singleSelect:true,
">
<thead>
<tr>
<th data-options="field:'date',width:75">DATE</th>
<th data-options="field:'acft',width:50">ACFT</th>
<th data-options="field:'loc',width:40">LOC</th>
<th data-options="field:'mttime',width:50">MTTIME</th>
<th data-options="field:'nxtsvc',width:50">NXTSVC</th>
<th data-options="field:'time',width:50,formatter:function(value,row){
return row.nxtsvc - row.mttime; //
},
styler:function cellStyler(value,row,index){
            if (value > 5 && value <= 10){
                return 'background-color:yellow;color:red;';
            } else if (value > 10){
             return 'background-color:red;color:yellow;'
            }
        }
">TIME</th>
<th data-options="field:'comments',width:100">COMMENTS</th>
</tr>
</thead>
« Last Edit: October 07, 2014, 03:47:15 PM by swells808 » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: October 07, 2014, 06:40:54 PM »

Please try the code below to define the 'time' column.
Code:
<th data-options="field:'time',width:50,
formatter:function(value,row){
return row.nxtsvc - row.mttime;
},
styler:function cellStyler(value,row,index){
var v = parseInt(row.nxtsvc) - parseInt(row.mttime);
if (v > 5 && v <= 10){
return 'background-color:yellow;color:red;';
} else if (v > 10){
return 'background-color:red;color:yellow;'
}
}
">TIME</th>
Logged
swells808
Newbie
*
Posts: 15


View Profile
« Reply #2 on: October 07, 2014, 07:06:01 PM »

Close!

The math function works and the first if statement works but it ignores the "else if" part of the code. What is missing?
Logged
chrwei
Full Member
***
Posts: 219


View Profile Email
« Reply #3 on: October 13, 2014, 01:10:30 PM »

shouldn't
Code:
styler:function cellStyler(value,row,index){

be

Code:
styler:function(value,row,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!