Monday 18 July 2016

Conditional Link in APEX Tabular Form

                      
Conditional link is the common requirement all over application development. As requirement goes with Users and Roles, Conditionally we may have to hide / disable link for different users and roles. Form level it will be easy. But when comes to tabular form, it is somewhat typical. I have done this in tabular form with JQuery, without using any loop which will lead to performance issue.

It has been done as Role-based Conditional link.

Step:1: Maintain hidden column in tabular form to maintain role against each entry.

Step:2: In Page Load and after refresh event include this
      Execute Javascript code event
      $("#report_del_item .t-Report-report      td[headers='GENERAL_COMMENTS']")
.each(function(){var a = $(this).children("input[name='f15']").val();
if (a =='Developer' || a =='Validator' || a =='Reviewer') {
         $(this).closest('tr').find("td[headers='TITLE'] a").attr( "href", "javascript:void(0);").css({"cursor":"default","color": "black"});

 } });
#report_del_item  - Static Id of Report.
td[headers='GENERAL_COMMENTS'] - Represents General Comments Column

$(this).children("input[name='f15']") - Represents role hidden column  id , Children been specified as all hidden columns will be children to last visbile/display column.

.closest('tr')  - Finds closest table row <tr>
.find(“td[headers='TITLE'] a”) - Finds selector with anchor in table data having header as ‘TITLE’ 
.attr( "href", "javascript:void(0);") - Sets attribute href to void which returns none
.css({"cursor":"default","color": "black"}) - Sets style with normal cursor and black colored font.

Output:


 Notice Title column on both screen shots , which is link but It is displayed conditionally






No comments:

Post a Comment