Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to conditionally format columns in an interactive grid using data from another column?

ZoieJun 14 2021 — edited Jun 14 2021

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.

Comments

Post Details

Added on Jun 14 2021
1 comment
1,813 views