Hello
I have an interactive grid with many columns of data, I want to make certain columns show a red/green background depending on the data to show whether or not the data is 'good' or 'bad'. I am using an interactive grid, but the main issue is I need to compare the celldata with another column's data.
For example, let's say I have a column called 'apples' and another column that is hidden called 'apple_target'. This determines the prices of apples for various stores and the average or target price. If apples is greater than(>) apple_target then the background to that cell would be red and so on.
I have been attempting this through the javascript under the function and global variable declaration by creating functions to color the backgrounds and calling them when the page loads with a dynamic action. My main problem stems from not being able to access the main target value. Here is an example of what I want to do:
function highlight_ig_apple_cells() {
$(".all td.apple_column_color").each(function(){
cellData = $(this).text();
if (cellData <= $v('APPLETARGET') && cellData > 0) {
$(this).addClass('u-success');
}
else if(cellData > $v('APPLETARGET')) {
$(this).addClass('u-danger');
}
else {
$(this).addClass('u-normal');
}
});
};
The 'apple_target' column is not being accessed. How do I access this column to compare it with the apples column? Also, the columns are all within my sql query.