6 Replies Latest reply: Oct 4, 2013 2:06 AM by vincent_deelen RSS

    How to get a radio group on a form with a dynamic action

    236f2a50-9fb9-4782-a643-3c80c2b10114

      Afternoon all (and thanks for helping).

       

      I have a requirement to have an APEX form that queries a table of unconfirmed rows, with a radio group on each row to either approve or reject the row.

      Ideally, when the radio group is selected, there should be a dynamic action that updates the row and refreshes the form (thus removing the processed row).

       

      Trouble is, I haven't a clue how to do it.

       

      I have tried by creating both an IR and TF, but neither allow me to have a dynamic action associated with the radiogroup.  Is it possible, and if so, how??

       

      Many thanks for any help,

        • 1. Re: How to get a radio group on a form with a dynamic action
          vincent_deelen

          Hi,

           

          Do you want to refresh the report after each confirmation, or do you want to allow users to select/confirm a number of rows and process them all at once? Last option can greatly enhance performance, since you don't need to reload your page (or page region) every time.

           

          Do you want to submit the entiry page, with a normal page submit process, or do you want to stay on the page and only refresh your region?

           

          Ow and what version of Apex do you use?

           

          Kind regards,

          Vincent

          • 2. Re: How to get a radio group on a form with a dynamic action
            236f2a50-9fb9-4782-a643-3c80c2b10114

            Ideally, refresh the report after each confirmation.

            Just refresh the region.

             

            I'm on Apex 4.1

            • 3. Re: How to get a radio group on a form with a dynamic action
              vincent_deelen

              Under the assumption that your table has a column of some kind that holds a value for confirmation Y/N, you can display that column as a radio button in your report. Use the apex_item.radiogroup function for that: APEX_ITEM

              Try to create a dynamic action with a pl/sql procedure to update the row/table and add an extra true action that does  a region refresh. For the dynamic action use 'click' as event and 'jQuery selector' as selection type. Your jQuery selector must be something like

              'input [type="radio"]'

               

              Please take in consideration that in the case someone mistakenly presses the radiobutton, the row will be processed and gone nevertheless.

              • 4. Re: How to get a radio group on a form with a dynamic action
                236f2a50-9fb9-4782-a643-3c80c2b10114

                Afternoon,

                 

                Thanks for that.  I now have an insert into a table whenever the radio button is selected.  However, I can't seem to reference the values in the report.  How do I do that?
                I have a basic report, and the radio button is defined in the select as:

                 

                select apex_item.radiogroup(1,approved) as app,

                apex_item.radiogroup(1,approved) as rej,

                ...other columns

                from the_table

                where approved is NULL;

                 

                The idea is that there are 2 radio buttons, one for Approved and one for Rejected.  If the user rejects, then the ID of the row would be used by the PL/SQL to remove it from the table.  If the user Approves, then the PL/SQL would update the table, setting the approved column to 'Y'.

                 

                However, I can't seem to reference any of the report columns in the PL/SQL block.

                 

                Do I need to use the other attributes of the apex_item function?

                 

                Any help much appreciated.

                • 5. Re: How to get a radio group on a form with a dynamic action
                  236f2a50-9fb9-4782-a643-3c80c2b10114

                  I could really do with some advice on this please.  The online documentation assumes a level of knowledge I don't have.

                   

                  I have created an Interactive Report like this:

                  select

                    apex_item.radiogroup(1,'A'||unique_id,null,null,'onClick="alert(value)"') as approved,

                    apex_item.radiogroup(1,'R'||unique_id,null,null,'onClick="alert(value)"') as rejected,

                    unique_id,

                    task_information

                  from task_details

                  where approved is null;

                   

                  So, when I click on a radio button, i get the correct unique_id prefixed with the correct status - A for approved etc.

                   

                  Is there some way I can tie the unique ID to the radio button to run in a PL/SQL query to update the database?

                  • 6. Re: How to get a radio group on a form with a dynamic action
                    vincent_deelen

                    Hi,

                     

                    You're pretty close. Try changing your radiogroups in the select statement to:

                    select apex_item.radiogroup( p_idx            => rownum

                                               , p_value          => 'Y'

                                               , p_selected_value => approved

                                               , p_display        => null

                                               , p_attributes     => null

                                               ) as APPROVED

                    ,      apex_item.radiogroup( p_idx            => rownum

                                               , p_value          => 'N'

                                               , p_selected_value => approved

                                               , p_display        => null

                                               , p_attributes     => null

                                               ) as REJECTED

                    ,         unique_id

                    ,        task_information

                    from   task_details

                    where approved is null;

                     

                    You can tie your unique_id and radiobutton together, based on the rownum. Or if the unique_id from task_details is numeric, you can use that directly instead of the rownum as p_idx.

                     

                    Regards,

                    Vincent