Tuesday 13 January 2015

Create Tooltips + Hyperlink To Another Component

I need two things today.

  1. Create a link for every row in the grid. Each link will transfer the page to a new component and use the search keys automatically.
  2. Create a hover or mouseover label for the links.

Step by step guide below.



  1. Create an HTML object (MYHTMLOBJECT) with the following value.
    <a href=%Bind(:3) title="%Bind(:2)" target="_blank"> %Bind(:1) </a>
    


  2. Add an HTML area field to a grid. Use a derived record field.

    We will refer to it as MYDERIVEDRECORD.DESCR254_MIXED.



  3. Add the following code to Page Activate.

    Each piece has an explanation.

    Local Rowset &RS;
    Local Record &Rec;
    Local number &i;
    Local string &Key1Value, &Final_String, &LinkName, &AdditionalParameterString, &Hover_Text, &TransURL;
    
    /* Get the grid rowset */
    &RS = GetLevel0()(1).GetRowset(Scroll.MYGRIDRECORD);
    
    /* Loop through grid rowset */
    For &i = 1 To &RS.ActiveRowCount
        
     &Rec = &RS(&i).MYGRIDRECORD;
     
     /* Set the link label */
     &LinkName = "Link: " | &Rec.ATTACHUSERFILE.Value;
    
     /* Assign the key values - hardcoded for this example */
     &Key1Value = (enter employee ID here);
     
     /* Create parameter string */
     &AdditionalParameterString = "&EMPLID=" | &Key1Value;
    
     /* Create the URL */
     &TransURL = GenerateComponentPortalURL(%Portal, %Node, MenuName.MYMENU, %Market, Component.MYCOMPONENT, Page.MYPAGE, "U") | &AdditionalParameterString;
    
     /* Create the mouseover link */
     &Hover_Text = "Hover for " | &LinkName;
     &Hover_Text = "";
    
     /* Generate hyperlink and assign the value to the HTML area field on the grid */
     &Final_String = GetHTMLText(HTML.MYHTMLOBJECT, &LinkName, &Hover_Text, &TransURL);
     &RS(&i).MYDERIVEDRECORD.DESCR254_MIXED.Value = &Final_String;
    
    End-For;
    


And here's the result.

No comments:

Post a Comment