user7285351
user7285351

Reputation: 67

How to only display 'Edit' link on certain rows on apex interactive grid?

I have an interactive report apex5.0 which contains several fields. Would like to disable 'edit' pencil option link where payment_date & code is populated. Link is to be enabled only where payment_date & code is null. Disable the edit button for a particular row, based on a specific value in its column.

For ex. If a grid has 3 columns A,B,C and if B contains "Apple", and '01-jan-17', the edit button for that row must be disabled.

What are the different options to do this kind of functionality in apex5.0, enable & disable "EDIT" based on certain criteria?

Upvotes: 1

Views: 6990

Answers (2)

Boris Serafimov
Boris Serafimov

Reputation: 635

One way is to use JavaScript on page load: Let's asume that first column is with ID and used to show edit link. Second column is your product name like Apple. Just disable click on this element(cell with ID) or change link, img etc.

var table = $(".a-IRR-table tbody");
table.find('tr').each(function (i, el) {
    var $tds = $(this).find('td'),
        productId = $tds.eq(0).text(), //first column with ID and edit link
        product = $tds.eq(1).text(),   //second column
        Quantity = $tds.eq(2).text();  //third column
if (product == 'Apple'){
    $tds.eq(0).click(false);
    $tds.eq(0).replaceWith('');
}
    
});

Thanks to this answer for JavaScript: Loop Through Each HTML Table Column and Get the Data using jQuery
EDIT: To hide value based on your Query use CASE. For example:

SELECT
 CASE
  WHEN B = 'Apple' THEN
    '<img src="#IMAGE_PREFIX#edit.gif" alt="">'
  ELSE ''
END edit_link,
A,B,C
FROM TABLE_NAME
  • Click on column edit_link and make it of type Link
  • Choose your target to edit page
  • For link text select #EDIT_LINK#
  • Escape special characters must be set to NO
  • On Report Atributes set **Link Column** to **Exclude Link Column** (you have custom link column so don't display original link)
    *Check your online workspace, page 3*

    Upvotes: 0

  • hisnameismyname2
    hisnameismyname2

    Reputation: 387

    You could also add a case statement to your report's query.

    E.g.

    (Case when [some logic] then
      --display link
     '<a href="f?p=' || :APP_ID || ':47:' || :APP_SESSION || '::NO:47:P47_ID:'|| a.id || '" title="Edit"><img src="#IMAGE_PREFIX#menu/pencil16x16.gif" alt="" /></a>'
      End) as col_link
    

    The above example will only display a link if the case statement is met. The link will point to page 47 and we will pass the query's Id column to page 47's item P47_ID

    In order to treat this new column as a link you must change the "display as text" property to "standard report column"; you can achieve this when editing the report attributes.

    Upvotes: 3

    Related Questions