5 Replies Latest reply: Apr 30, 2012 7:51 AM by Prabodh RSS

    How to retain selected value in apex_item.select_list?

    689515
      Hi,
      I've a report region query-
      select distinct col1, col2,
      APEX_ITEM.HIDDEN(2,col3)||
      APEX_ITEM.SELECT_LIST(1,'No_Action','Valid;Y,Invalid;N') Action
      from <tab1>

      When 'Y' (valid) selected from the select list and SUBMIT is clicked - a validation and then page processing pl/sql process will run for the record, branching to the same page.
      If validation fails custom error message comes on screen, but value of column "Action" is reset to default 'No_Action'.

      Can anyone please tell me how can I show the last selected value in column "Action"?

      Please reply asap. Regards.
        • 1. Re: How to retain selected value in apex_item.select_list?
          VC
          user995809 wrote:
          Hi,
          I've a report region query-
          select distinct col1, col2,
          APEX_ITEM.HIDDEN(2,col3)||
          APEX_ITEM.SELECT_LIST(1,'No_Action','Valid;Y,Invalid;N') Action
          from <tab1>

          When 'Y' (valid) selected from the select list and SUBMIT is clicked - a validation and then page processing pl/sql process will run for the record, branching to the same page.
          If validation fails custom error message comes on screen, but value of column "Action" is reset to default 'No_Action'.

          Can anyone please tell me how can I show the last selected value in column "Action"?

          Please reply asap. Regards.
          Try redirecting to error page when validation fails. (means edit the validation and chose Error message display location as Error Page)

          Thanks
          • 2. Re: How to retain selected value in apex_item.select_list?
            Prabodh
            To be able to show the last selected value you need to make the value persistent, that is update it in some column in the table.

            So the next time the report is run (refreshed) it fetches the value from the table/column . Then change your query to something like
            select distinct col1, col2,
            APEX_ITEM.HIDDEN(2,col3)||
            APEX_ITEM.SELECT_LIST(1,NVL(COL_YN,'N'),'Valid;Y,Invalid;N') Action
            from <tab1>
            COL_YN is the column where you stored the last selection. Unless you store it in some table/column you cannot get it back into the report when it is refreshed.

            The other way of course is to use APEX_COLLECTIONS , but that might be more complex.

            However, you need to think whether you really need the APEX_ITEMs API for this? If you just edit the Report Attributed and Edit the column definitions you might be able to achieve the same thing without having to use APEX_ITEM.

            Regards,
            • 3. Re: How to retain selected value in apex_item.select_list?
              689515
              Hi,
              Column "Action"(=apex_item.select_list()) is not present in table. This is an action expected from the user whether to allow this record saying valid or discard saying invalid. I've attached apex_item.hidden(col3) to be used as primary_key on the row.

              Is there any property available in Report Region or apex_item.select_list that previous value selected in the item can be cached throughout the session?

              Please reply. Regards.
              • 4. Re: How to retain selected value in apex_item.select_list?
                Prabodh
                Short answer "NO".

                If you want to retain the value after submit for tabular you have to make it persistent, in table or Apex_collection.

                Regards,
                • 5. Re: How to retain selected value in apex_item.select_list?
                  902143
                  Hi,

                  This is not a best approach, but Why don't you create an application item and when user selects a value from the list item save it to the created application item and when page loads branched back to same page check if the application item holds any value if then set the app item value to your select list. won't this work ?