0

I want to update Interactive grid Column Heading Name dynamically in oracle apex on the basis of month selected from list.

For example I have selected August from Month LOV then the column heading should be display like this.

01/MON, 02/TUE, 03/WED .............. 28/SAT,29/SUN,30/MON.

Previous Research

Code: I try to CONCATENATE date like this.

---------------For First Column Heading-----------
SELECT '01'||' / '|| TO_CHAR(:P152_START_DATE,'DAY')
FROM DUAL;
---------------For First Column Heading-----------
SELECT '02'||' / '|| TO_CHAR(:P152_START_DATE+1,'DAY')
FROM DUAL;

This is the interactive grid having column heading from 01-Aug-2021 to 31-Aug-2021.

Javaid
  • 1
  • 2

1 Answers1

1

A column header supports substitutions, so this is one solution.

  • Create 31 page items P152_COL1 up to P152_COL31.
  • Set page item for each column heading using substitution syntax (example &P152_COL1. )
  • Create a page process to populate the column header page items
BEGIN
FOR r IN 
(SELECT TO_CHAR(TRUNC(TO_DATE(:P152_START_DATE, 'DD-MON-YYYY'),'MM') + level - 1,'DD/DY') AS wd,
 TO_DATE(:P152_START_DATE, 'DD-MON-YYYY') + level - 1 as dt,
 level - 1 as rn 
FROM dual CONNECT by level < 32)
LOOP
  --only include the days of the selected month, else print "-"
  IF TRUNC(r.dt,'MM') = TRUNC(TO_DATE(:P152_START_DATE, 'DD-MON-YYYY'),'MM') THEN
    APEX_UTIL.SET_SESSION_STATE('P152_COL'||r.rn,r.wd);
  ELSE
    APEX_UTIL.SET_SESSION_STATE('P152_COL'||r.rn,'-');
  END IF;
END LOOP;
END;

Note that I assumed date format DD-MON-YYYY for the P152_START_DATE page item - adjust as needed for your project

Koen Lostrie
  • 14,938
  • 2
  • 13
  • 19