Search code examples
oracle-apexoracle-apex-5

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?


Solution

  • 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*