3 Replies Latest reply: May 24, 2013 3:44 PM by KarenH RSS

    what is best way to hide/show tab. form columns based on another column val

    KarenH
      Hi Everyone,

      I am using apex 4.2. I am proficient in sql/plus and very very very new to jQuery and javascript.

      I have created a tabular form based on a view (landings_collection_view) which looks at a collection 'SPECIES_COLLECTION'.

      I am able to update/add/delete to my tabular form using dynamic actions.

      I am now trying to hide/show several columns based on the value of another column and wondering the best way to do it.

      Currently I have:

      2 page items:
      P113_ID
      P113_VALUE

      Dynamic action called CHANGE COLUMN:
      event: CHANGE
      selection type: jQUERY Selector
      jQuery:
      select[name=#DISPOSITION_CODE#],select[name=#GEAR_CODE#],input[name=#REPORTED_QUANTITY#],input[name=#PRICE#],input[name=#DOLLARS#],select[name=#HMS_AREA_CODE#],input[#FINSATTACHED#],input[#FINSNOTATTACHED#],input[#FINSUNKNOWN#],input[#HMSFLAG#]
      event scope: Dynamic

      true action#1: set value P113_ID javascript expression this.triggeringElement.id
      true action#2: set value P113_VALUE javascript expression this.triggeringElement.value
      true action#3: execute pl/sql code
      declare
      
        v_member number;
        v_seq number;
      
      begin 
        v_member := TO_NUMBER (SUBSTR (:p113_id, 2, 2));
        select ltrim(substr(:p113_ID,5,4),'0') into v_seq from dual;
      
        safis_collections.update_column(v_seq,
                                      v_member,
                                      :p113_value);
      end;
      true ation#4 refresh region :LANDINGS_COLLECTION

      the tabular form is based on the query:
      select 
      NULL del_link, 
      v.seq_id, 
      v.seq_id seq_id_display,
      s.common_name||'-'||m.market_desc||'-'||g.grade_desc||'-'||u.unit_desc species,
      v.LANDING_SEQ,
      v.SPECIES_ITIS,
      v.GRADE_CODE,
      v.MARKET_CODE,
      v.UNIT_MEASURE,
      v.DISPOSITION_CODE,
      v.GEAR_CODE,
      v.REPORTED_QUANTITY,
      v.PRICE,
      v.DOLLARS,
      v.AREA_CODE_FLAG,
      v.C014,
      v.ADDITIONAL_MEASURE_FLAG,
      v.ADDNL_REPORTED_QUANTITY,
      v.ADDNL_UNIT_QUANTITY,
      v.AREA_FISHED,
      v.SUB_AREA_FISHED,
      v.LOCAL_AREA_CODE,
      v.FINS_FLAG,
      v.FINSATTACHED,
      v.FINSNOTATTACHED,
      v.FINSUNKNOWN,
      v.FINS_CODE,
      v.EXPLANATION,
      v.NATURE_OF_SALE,
      v.HMS_AREA_CODE,
      v.SALE_PRICE,
      v.HMS_FLAG
      from  LANDINGS_COLLECTION_VIEW v, 
            species s, 
            market_categories m, 
            grade_categories g, 
            units_of_measure u
      where v.species_itis = s.species_itis and 
            v.market_code = m.market_code and 
            v.grade_code = g.grade_code and
            v.unit_measure = u.unit_measure
      the column HMS_FLAG is hidden and the value is Y or N. It is loaded when a species is selected from a tree. If the value is 'Y' then I would like to show the column FINSATTACHED, FINSNOTATTACHED, and FINSUNKNOWN. If it is set to 'N' then those columns should be hidden.

      I am not certain if this logic should be a new Dynamic Action or another true action added to the dynamic action CHANGE COLUMN and wondered your thoughts.

      of course, I also want the answer. sigh. How do I do this? what are the statements I should be looking for? can it be done with pl/sql to reference a column/row in a tabular form...or is javascript the only way?

      thank you!

      Karen
        • 1. Re: what is best way to hide/show tab. form columns based on another column val
          InoL
          I am now trying to hide/show several columns based on the value of another column and wondering the best way to do it.
          This requirement doesn't make sense to me really. It's like saying "when the name is SMITH, don't show the first name". In a tabular form, you would get this?
          Name   FirstName   DoB
          JONES  JOE         12-JAN-1978
          SMITH  21-MAR-1990
          You hide FirstName so that the DOB column shifts to the left. Is this what you want?
          • 2. Re: what is best way to hide/show tab. form columns based on another column val
            KarenH
            thanks for your response. THe position of HMS_FLAG (before or after other columns) doesn't really matter as it is hidden. The HMS_FLAG is set when a species is selected from a tree. The application is for commercial fishers and the select the fish species they have caught. If the species is a highly migratory species (HMS) such as shark or tuna, then the HMS_FLAG is automatically set to Y and the checkboxs of FINS ATTACHED? FINS NOT ATTACHED? and FINS UNKNOWN are displayed.

            If on loading the species it is not an HMS Species (HMS_FLAG=N) then those check boxes will not appear for that row. Ideally, the columns would not shift, but just a blank would appear. If that is not possible, then the value 'N/A' could appear.

            hope you understand. thanks again.

            Karen

            Edited by: KarenH on May 24, 2013 3:23 PM
            • 3. Re: what is best way to hide/show tab. form columns based on another column val
              KarenH
              my formatting may be wrong, but basically, I was thinking I could create another dynamic action called HMS_FLAG
              event: change
              selection type jQuery Selector
              jQuery selector: input[name='f29'] (f29 is hms_flag)
              condition: equal to N

              true action#1 HIDE jQuery $('f21').hide(); (f21is finsattached)

              Edited by: KarenH on May 24, 2013 4:44 PM