Astro
Astro

Reputation: 115

How to add edit button to only some rows meeting specific condition in oracle apex report

i want to add edit button to some specific rows only in a oracle apex report.suppose i want an edit button only in those rows having job = manager. after clicking that button i will be redirected to another page present in my application.please help regarding these.

Upvotes: 0

Views: 976

Answers (1)

Tony Andrews
Tony Andrews

Reputation: 132570

You can do this by adding a column of type Display As Text, with Escape Special Characters set to No, defined in the report SQL something like:

 ...
 case when e.job = 'MANAGER' then
   q'[<input type="button" value="Edit" onclick="redirect(']'
   || apex_page.get_url
        ( p_page => 123
        , p_items => 'P123_EMPNO'
        , p_values => e.empno
        )
   || q'[')" class="myButtonClass">]'
 end as edit_button

In this example, when clicked the button will redirect to page 123 of the same application and pass this row's empno value into item `P123_EMPNO'.

You can use the class attribute to apply classes for styling - you may want to use Universal Theme class names like 't-Button' for consistency.

Applied to your SQL from comment below:

SELECT apex_item.checkbox(1,empno,'UNCHECKED') " ",
       empno, ename, job, hiredate, sal, comm,
       case when job = 'MANAGER' then
         q'[<input type="button" value="Edit" onclick="redirect(']'
         || apex_page.get_url
              ( p_page => 123
              , p_items => 'P123_EMPNO'
              , p_values => empno
              )
         || q'[')" class="myButtonClass">]'
       end as edit_button
  from emp;

Upvotes: 2

Related Questions