4 Replies Latest reply: Mar 10, 2014 6:13 PM by fac586 RSS

    Apex menu displaying alphabetically

    Jezzer

      Hi,

       

      I have defined an APEX menu using the standard functionality. The items which are in that menu were not entered in alphabetic order. A couple of the items have condition statements against them to determine when they display.

       

      Is there a way, without changing the sequence numbers, to get the menu to display in alphabetic order, as the default is to display in sequence number order?

       

      In another menu I got around this problem by creating a second dynamic list which selected from the original one and displayed it in alphabetic order, using the following SQL:

       

      select

        null,

        entry_text label,

        entry_target target,

        null is_current_list_entry,

        entry_image image,

        entry_image_attributes image_attribute

      from apex_application_list_entries

      where workspace = 'DEV'

      and application_id = 104

      and list_name = '&DEV_PAGE_FORM_NAME.'

      order by upper(entry_text)

       

      This works great except that it does not take into the conditional display statements. I am struggling to integrate these as I cannot see how to execute the condition in the condition_expression1 column. The condition is pl/sql returning boolean. I was going to create a function which used execute immediate, however this cannot use boolean data types, so that is a non-started.

       

      The condition is of the form:

       

      "if nvl(v('DEV_SYSTEM_CONFIG'),'XXXXXX') = 'C' then

        return true;

      else

        return false;

      end if;"

       

      Any ideas either,

       

      1. How to get the original menu to display alphabetically without having to reorder the sequences each time the menu is edited

       

      2. How to execute the condition statement in condition_expression1 as part of the above SQL.

       

      Any help gratefully received.

       

      Jeremy

        • 1. Re: Apex menu displaying alphabetically
          Jezzer

          Ok, so I have managed to progress this one somewhat.

           

          If the condition statement is just a matter of checking whether an item equals some value then adding the following to my dynamic list query works a treat:

           

          select

            null,

            entry_text label,

            entry_target target,

            null is_current_list_entry,

            entry_image image,

            entry_image_attributes image_attribute

          from apex_application_list_entries

          where workspace = 'DEV'

          and application_id = 104

          and list_name = '&DEV_PAGE_FORM_NAME.'

          and (

            (condition_type_code = 'VAL_OF_ITEM_IN_COND_EQ_COND2' and apex_util.get_session_state(condition_expression1) = condition_expression2) or condition_type_code is null

              )

          order by upper(entry_text)

           

          Would still be nice to know how to handle this if it is not just a simple equality statement.

          • 2. Re: Apex menu displaying alphabetically
            fac586

            It's a nice creative workaround, but as there are a lot of possible conditions and no documented API for evaluating them, a fully comprehensive and generic solution that handles all of them is probably impractical.

             

            • What are these list entries?
            • Why is it necessary for them to appear in alphabetic order?
            • How many list entries are there?
            • How many different conditions are involved? (Noting that the VAL_OF_ITEM_IN_COND_EQ_COND2 condition handled in your second post differs from the PL/SQL Boolean function type described in the first)
            • How many lists are involved?
            • How many pages are they displayed on?
            • Will the list and/or conditions be subject to significant changes over time?
            • Is the application likely to be translated to another language that would require different sort semantics?
            • What APEX version are you using?
            • What browser(s)/version(s) are you using?

             

            My initial thinking would be to have APEX to render the original list—which would obviously process the conditions normally—and re-order the resulting elements using a JavaScript dynamic action when the page hits the browser.

            • 3. Re: Apex menu displaying alphabetically
              Jezzer

              Thanks for your response.

               

              The list entries vary. Some point to other pages, some open up a new window, depending on how the functionality is related to the current page.

              They need to appear alphabetically as that is deemed user-friendly. Also, as the list entries are conditional, the order may be different for different people/pages. The same base list is called for a number of similar pages, although some of the list-entries displayed are different.

               

              Currently about 15 in total, although probably only 8-10 displayed at any one time.

               

              At the moment, the only conditions are that shown or based on the page number, hence why I used the above SQL.

               

              Currently only 4, although this will increase. We are rewriting a old large complex forms appellation in APEX.

               

              Number of pages varies, but can be unto 6 different pages for the same "set" of list entries

               

              Changes over time, possibly not, although as we are in the development stage at the moment, and the application will be released to customers in stages the menus will change.

               

              Yes, the application may well be translated.

               

              Apex 4.2

               

              Browsers mainly IE, although also possibly Firefox or Chrome. Having said that I am developing using Safari.

               

              Could you give an example of your possible solution?

              • 4. Re: Apex menu displaying alphabetically
                fac586

                Jezzer wrote:

                 

                Could you give an example of your possible solution?

                Assuming the list region has the static ID menu, create a global (page zero) dynamic action, with a "Page In" condition for the pages displaying the menu:

                 

                When

                 

                Event: Page Load

                 

                True Actions

                 

                Action: Execute JavaScript Code

                Fire On Page Load: No

                Code

                $('#menu ul').children('li').sort(function (a, b) {
                  var A = $(a).text().toUpperCase();
                  var B = $(b).text().toUpperCase();
                  return (A < B) ? -1 : (A > B) ? 1 : 0;
                }).appendTo('#menu ul');
                
                
                

                 

                If the application is translated and the list entries are not in "alphabetical" order for the language/territory involved, look at using localeCompare in the sort function comparison (I have no experience with either APEX translations or using localeCompare in JS).

                 

                Message was edited by: fac586

                 

                Ignore the "<span><span><span><span><span><span>" nonsense: it's an artefact of the appalling Jive forum software.