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)

No default    With Default Column

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;});

Hi, I'm Jorge Rimblas. Father, husband, photographer, Oraclenerd, Oracle APEX expert, Oracle ACE, coffee lover, car guy, gadget addict, etc... I'm an APEX Tech Lead DRW. I have worked with Oracle since 1995 and done eBusiness Suite implementations and customizations. Nowadays I specialize almost exclusively in Oracle APEX.

9 Comments on “Default IR Search Column

  1. Needed to learn about Dynamic Actions to use this – done
    Technique works
    ++Pleased

  2. 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.

    • 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.

    • 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.

Leave a Reply to Varad Cancel reply