Single Article

Adding help text to column headings in a tabular form

Category APEX Tricks

There is no out of the box solution for adding help text to column headings in a tabular form.

One way is create custom table where you store your help text.
Then modify/copy report template and add JavaScript that fetch using Ajax call help text for your column.

In report template I did change Column Heading Template to be:

<th id="#COLUMN_HEADER_NAME#" onmouseover="getColumnHelp(event,this,'#COLUMN_HEADER_NAME#')">#COLUMN_HEADER#</th>

Then I did add to After Rows:

<script type="text/javascript">
function getColumnHelp(pEvent,pThis,pColumn){
  var ajaxRequest = new htmldb_Get(null, $v('pFlowId'), 'APPLICATION_PROCESS=GET_REPORT_HELP', 0);
  ajaxRequest.addParam('x01', pColumn);
  ajaxRequest.addParam('x02', '#REGION_ID#');
  var ajaxResponse = ajaxRequest.get();
  ajaxRequest = null;
  toolTip_enable(pEvent,pThis,ajaxResponse);
}
</script>

 

And then on demand process GET_REPORT_HELP

DECLARE
  l_help_text VARCHAR2(255);
BEGIN
 
  SELECT help_text
  INTO l_help_text
  FROM DEMO_REPORT_COL_HELP
  WHERE COLUMN_HEADER_NAME = APEX_APPLICATION.G_x01
  AND REGION_ID  = APEX_APPLICATION.G_x02
  ;
 
  htp.prn( REPLACE(REPLACE(l_help_text, chr(10), '\f'), chr(13)) );
 
EXCEPTION WHEN NO_DATA_FOUND THEN
  htp.prn('No help available for this item');
END;

 

This is my custom help text table DLL:

CREATE TABLE "DEMO_REPORT_COL_HELP" 
   (    "ID" NUMBER NOT NULL ENABLE, 
    "COLUMN_HEADER_NAME" VARCHAR2(30 BYTE) NOT NULL ENABLE, 
    "REGION_ID" VARCHAR2(20 BYTE) NOT NULL ENABLE, 
    "HELP_TEXT" VARCHAR2(255 BYTE), 
    "RESERVED2" VARCHAR2(20 BYTE), 
    "RESERVED3" VARCHAR2(20 BYTE), 
    "RESERVED4" VARCHAR2(20 BYTE), 
    "RESERVED5" VARCHAR2(20 BYTE), 
    "CREATED_ON" DATE NOT NULL ENABLE, 
    "CREATED_BY" VARCHAR2(255 BYTE) NOT NULL ENABLE, 
    "CHANGED_ON" DATE, 
    "CHANGED_BY" VARCHAR2(20 BYTE), 
     CONSTRAINT "DEMO_REPORT_COL_HELP_PK" PRIMARY KEY ("ID"));

 

And trigger for it:

create or replace TRIGGER "BIU_DEMO_REPORT_COL_HELP" before
  INSERT OR UPDATE ON "DEMO_REPORT_COL_HELP" FOR EACH row 
BEGIN 
 
  IF inserting THEN 
    
    IF :NEW.ID IS NULL THEN 
      SELECT TO_NUMBER(SYS_GUID(), 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
      INTO :NEW.ID
      FROM DUAL;
    END IF;
    
    :NEW.CREATED_ON := sysdate;
    :NEW.CREATED_BY := NVL(v('APP_USER'),user);
    :NEW.CHANGED_ON := null;
    :NEW.CHANGED_BY := null;
  END IF;
  IF updating THEN
    :NEW.CHANGED_ON := sysdate;
    :NEW.CHANGED_BY := NVL(v('APP_USER'),user);
  END IF;
  
END;

See working example.

Comments

  • sandeep · 20 Sep 2016  

    Hi Jari,

    You are right, the new requirement that I have asked it's not related to this blog post. That is altogether new requirement.

    Sorry if you disliked the question asking in this blog post.

    To be honest this is first time I have been doing this kind of activity, so please bare with me.

    Regards,

    Sandeep G.

        
  • Jari Laine · 19 Sep 2016  

    Hi Sandeep,

    I don't understand how those requirements relates this blog post.

    Regards,
    Jari

        
  • sandeep · 18 Sep 2016  

    Hi Jari,

    Sorry for the late reply and thank you for your tips.

    Now I have 1 new requirement as described below.

    I have 1 tabular form & there is 1 column called 'entry_status'. It has 2 values 'Forecast' & 'Realised'.

    1) Now my requirement is if user selects entry_status as 'Realised' for the existing row OR add new row with 'Realised' entry_status & apply changes then entire row should be freezed.i.e. it should become non-editable.

    But after doing apply changes if some validation error comes then that row should not become non-editable, it should allow to edit all columns of that row.

    Also while doing above all things, existing saved rows should not be affected.(i.e. rows with entry status 'Realised' should be non-editable)

    2) My 2nd requirement is similar to above if user selects entry status as 'Forecast', but this time only few columns should become non-editable and not entire row.

    Rest of the criteria's remain the same.

    I would be grateful if you provide any help on this.

    Regards,

    Sandeep G.

        
  • Jari Laine · 8 Sep 2016  

    Hi Sandeep,

    First copy your favorite report template and change Column Heading Template.

    Then place JavaScript to same report template After Rows section at end.

    Regards,
    Jari

        
  • sandeep · 5 Sep 2016  

    Hi,

    The solution here provided here is the absolute for my requirement.

    But I dont know where to put that javascript & ajax script in apex application.

    I am new to apex.

    Could you please provide help on this?

    Thank you.

    Regards,

    Sandeep G.

        

Global Right Column

Search

Archives

Subscribe in a Reader