Forum Stats

  • 3,815,486 Users
  • 2,259,040 Discussions
  • 7,893,135 Comments

Discussions

How to add toggle button in Interactive Report

Pritam Das
Pritam Das Member Posts: 36 Green Ribbon
edited Dec 22, 2021 1:57PM in APEX Discussions

Hi Expert,

I have a requirement where i need to add a toggle button in interactive report and also once user toggle, the report should get refresh .

How we can achieve this functionality in oracle apex.

Apex version : 20.2.0.00.20

Regards,

Pritam

Tagged:

Answers

  • fac586
    fac586 Senior Technical Architect Member Posts: 20,808 Red Diamond

    I have a requirement where i need to add a toggle button in interactive report and also once user toggle, the report should get refresh .

    What do you mean by "toggle button"?

    Where is this to appear in the interactive report?

    Why should the report be refreshed when the switch is toggled? What action/process is really involved?

  • Pritam Das
    Pritam Das Member Posts: 36 Green Ribbon

    Hi,

    we need toggle in interactive report because we have a one column called flag where we have value either 'Y' or 'N'.

    So when user toggle it to 'ON' that moment the report should refresh and update the table with flag 'Y'.

    Similarly when when toggle it to 'OFF' the report should refresh and update the table with flag 'N'.

    I hope i explained the requirement properly.

    Regards,

    Pritam

  • InoL
    InoL Member Posts: 9,800 Gold Crown

    It doesn't make much sense. If you have a Y/N value column, every record in the table has a Y/N value.

    So, what is "update the table"? Just that one record in the table? You don't need to refresh the whole report for that, as it only changes the one record that you just changed.

    Furthermore, why use Interactive Report for this requirement? Create an Interactive Grid with a Switch type column.

  • StewStrykerNH
    StewStrykerNH Member Posts: 90 Blue Ribbon

    I might have an idea what he's driving at?

    So when user toggle it to 'ON' that moment the report should refresh and update the table with flag 'Y'.

    Similarly when when toggle it to 'OFF' the report should refresh and update the table with flag 'N'.

    I'm imagining a vacation request approval system, where the IR shows all the staff requests for vacation time. Steps:

    1. Above the IR is a region with Pritam's toggle button, which has Y/N values.
    2. On the IR, the Approved column is NULL.
    3. The manager filters to show the requests they want to approve.
    4. Then they click the Toggle button to Y
    5. The filtered records get updated to Y
    6. The IR refreshes, showing that the Approved column is now Y.

    JMHO, but I would use traditional buttons, not a toggle, since the toggle usually has a default value.

    In this scenario, I'd envision would call a Dynamic Action that would:

    1. Run a Execute PL/SQL Code script that passes the Apex collection with the primary keys of the filtered IR rows and the Button value (Y/N) to a compiled stored procedure. That procedure uses the primary keys to update the underlying table to the Button value.
    2. Refresh the IR region.

    You can Google for the method for getting the primary keys for the IR.

    Pritam, if I guessed right, please mark this answer Correct.

  • InoL
    InoL Member Posts: 9,800 Gold Crown

    I might have an idea what he's driving at?

    That's a pretty wilde guess indeed 😃

  • Pritam Das
    Pritam Das Member Posts: 36 Green Ribbon

    Hi Stew,

    Your understanding is correct.I will follow the approach that you have mentioned and update you.

    Regards,

    Pritam

    StewStrykerNH
  • StewStrykerNH
    StewStrykerNH Member Posts: 90 Blue Ribbon

    Does that make me a "wild and crazy guy"? 🤪

    It seems that I guess right, which confirms the old saying that "even a blind pig can find an acorn once in a while"! 😁