Default IR Search Column
If you want to default the search column in an Interactive Report, you can easily accomplish this with a Dynamic Action on the After Refresh event of your IR. This way instead of the report searching all columns, it will search the one you set it to (unless the user selects something different, of course)
Dynamic Action: Set Default IR Search Column
Event: After Refresh
Selection Type: Region
Region: select the IR region on your page
Condition: JavaScript expression with the code:
$v("apexir_CURRENT_SEARCH_COLUMN") == ""
True Action: “Execute JavaScript Code” with the following code:
$s("apexir_SEARCH_COLUMN_DROP", "Empno"); $s("apexir_CURRENT_SEARCH_COLUMN", "EMPNO");
Make sure it does fire on Page Load.
There are two values that need to be set. What the user sees on the screen “apexir_SEARCH_COLUMN_DROP” and what the IR will use as a column “apexir_CURRENT_SEARCH_COLUMN”, make sure this last one matches your column name.
By using the After Refresh event we make sure the default search column is set again after the report refreshes.
UPDATE March 15, 2017: If you’re on APEX 5.0 or later and need to remove the “All Columns” option, use this line of code provided by John Snyders. His blogs on working with the menu widget will help you a lot.
$("#{your-static-id-here}_column_search_drop").on("menubeforeopen", function(event, ui) {ui.menu.items[0].hide = true;});
Needed to learn about Dynamic Actions to use this – done
Technique works
++Pleased
Had to update the code a little bit for APEX 5.
the hidden item containing the column is now called ‘_column_search_current_column’.
To set the placeholder as well, you need to call
$(‘#e_search_field’).attr(“placeholder”, “Search: “);
as well in the True Action.
Great! Thanks for sharing
Okay the formatting seems to have stripped some of the characters of my comment.
Trying it again:
change ‘$$REPORT_STATIC_ID$$_CURRENT_SEARCH_COLUMN’ to ‘$$REPORT_STATIC_ID$$_COLUMN_SEARCH_CURRENT_COLUMN’
And call $(‘#$$REPORT_STATIC_ID$$_search_field’).attr(“placeholder”, “Search: $$COLUMN_TITLE$$“); to set the placeholder.
The $$…$$ parts need to be adjusted depending on your report / page.
This solution doesn’t work for me in APEX 20. Would you know why ?
You’re asking about the default column? Once IR’s got enhanced for multiple IR’s on a page this solution stopped working (except for removing the “All” option).
Sorry, I don’t know of a straightforward way to default a column. All my ideas would involve convoluted hacks.
Sorry, I haven’t worked with newer APEX versions, so I cannot give you any help on this
OK. Hope Jorge can help..
Thanks for the update Jorge.