Ihave below javascript code in , button click dynamic action :-
var model = apex.region("DETAIL_GRID_ID").widget().interactiveGrid("getViews", "grid").model;
var v_data_type, v_col1;
v_data_type = model.getFieldKey("DATA_TYPE");
v_col1 = model.getFieldKey("COL1");
model.forEach(function(r) {
console.log(r[v_data_type] +" "+ r[v_col1]);
if(r[v_data_type] == 'Change_color')
{
console.log('In Change_color');
//Here I want to change color of that cell text
//apex.item( "COL1" ).setStyle( "color", "red" );
}
});
SupriyaJain
Colour of the cell text should be retained. It should look like as below
afzal
STEP 1..
ASSIGN CLASS NAME IN YOUR INTERACTIVE GRIDE
Appearance-->CLASS--> highlight
STEP 2..
ASSIGN CLASS NAME IN YOUR "DATA TYPE" COLUMN OF IG
Appearance-->CSS Classes--> DATA_TYP
STEP 3..
ASSIGN CLASS NAME IN YOUR "COL1" COLUMN OF IG
Appearance-->CSS Classes-->COL_1
STEP 4..
CREATE JAVASCRIPT FUNCTION -- AND KEEP AT "Function and Global Variable Declaration"
function color_ig_cells() {
// for each cell in marked column
$('.highlight td.DATA_TYP').each(function() {
// get cell text
cellData = $(this).text();
if (cellData == 'Change_color'){
$(this).closest('tr').children().each(function(){
//console.log($(this).attr('class'));
var str=$(this).attr('class');
if (str.includes('COL_1')){
$(this).css({"color":"red"});
}
});
}
})
};
STEP 5-- CALL THIS ABOVE FUNCTION color_ig_cells() from "Execute when Page Loads" section
step 6-- create after refresh ig dynamic action and call this function "color_ig_cells()"
SupriyaJain
HI Afzal,
Thanks for the reply.
It is not working. In str var, it is not getting COL_1.
var str=$(this).attr('class');
afzal
hi,
check step no.3
STEP 3..
ASSIGN CLASS NAME IN YOUR "COL1" COLUMN OF IG
Appearance-->CSS Classes-->COL_1
SupriyaJain
Yes, dis the changes as below. Not working.
afzal
can you see o/p of console.log($(this).attr('class')); ?
SupriyaJain
Yes - It is coming like - a-GV-cell u-tE
SupriyaJain
It is working now. Thanks for the help!
Getting COL_1 in console.log($(this).attr('class'));
Timo Herwix
Can you try this step by step Post —> https://tm-apex.blogspot.com/2020/08/highlight-cells-based-on-value.html
SupriyaJain
https://tm-apex.blogspot.com/2020/08/highlight-cells-based-on-value.html
This works fine, when we have to change color of same column values. However, my case is, based on one column value, other column's text color gets changed, for the same row.
SupriyaJain
Another question. DATA_TYPE column will be hidden, then how to Assign CSS class to it?
SupriyaJain
When I toggle between Page Numbers at the bottom of IG region, color_ig_cells() function not gets called. What is the event that gets fired when toggle between different pages .
SupriyaJain
Called color_ig_cells() in Page change event. It is working now. Thanks!