Search code examples
javascriptoracleoracle-apexapex

How to clear/reset a row filter Apex


I have a Interactive Report that I would like to reset the row filter, programmatically.

Filter

I would like to know if this is possible, either dynamicly or by other means.

apex.region("IR").widget().interactiveGrid("getActions").invoke("reset-report");

and

apex.region("IR").call("getActions").invoke('reset-report');

But these are both referencing a report and this is a row filter?

I was able to do it coming from another linked page with the following. link reset

But I think it would be better done via a page load to cover all other pages that arn't linked?

Tried this before header with no luck:

Pre-Rendering Process

Process settings

Found a new issue releated to clicking the next arrow button on the pagination, this does reset the filter. It would be only necessary to reset the filter if we leave the current page_id. Example we are on page_id 4 and we are hitting the next button to see all of the data in the IR with the current filter,only if we leave page_id 4 is when we need to reset the filter.

next arrow


Solution

  • An Interactive Report (IR) region and and Interactive Grid (IG) region are 2 components with a very different architecture. The IR is a lot "older" (introduced in APEX 3.2), is more "server-based" and does not have a client model (and the corresponding javascript programming options) that the IG has. The IG javascript calls you are showing in your question will never work for an IR because it doesn't have any client architecture listening for those actions.

    Originally, the only way to reset a filter on a page is by doing so through the URL. However, in APEX 5 the API APEX_IR was added so the report filters can be cleared or reset on page load in a page process: for example:

    DECLARE
      l_region_id apex_application_page_regions.region_id%TYPE;
    BEGIN
      SELECT region_id 
        INTO l_region_id
        FROM apex_application_page_regions 
       WHERE application_id = :APP_ID and page_id = :APP_PAGE_ID and static_id = 'emp';
        APEX_IR.CLEAR_REPORT(
            p_page_id   => :APP_PAGE_ID,
            p_region_id => l_region_id,
            p_report_id => NULL);
     END;
    

    The code above needs to go in page process and the assumption is that the IR has a static id of emp