I want to hide/show columns in my interactive grid depending on condition. So far I wrote this:
function Filter_columns(column_name)
{
var grid = apex.region("report-form").widget().interactiveGrid("getViews", "grid");
var col_total = grid.model.getRecordValue("t1000", column_name).replace(',', '.');
if (parseFloat(col_total))
grid.view$.grid("showColumn", column_name);
else
grid.view$.grid("hideColumn", column_name);
}
If total sum by column equals 0, then hide it, otherwise show it. I am trying to compress table because it has 74 columns. Next step is to iterate through all columns. Obviously I can make an array of column names and iterate it, but is there a "proper" way to get column list of interactive grid? Apex version 23.2.0.
2
Answers
After searching extensively Oracle APEX JavaScript API Reference, I updated my function:
It works if i call it from console. But when I add this function to "Execute when Page Loads" section, I get this exception:
Edit: I used async call with delay:
And then added asyncCall() to Execute when Page Loads.
You can use the public grid getColumns method in interactivegridcreate event which is fired after the grid has been created with initial data but before apexreadyend/theme42ready. Place code in ‘Function and Global Variable Declaration’.
The interactivegridviewchange event fires even a little bit earlier with data.created = true, before the first selectionchange event