Delete a Row of a Report with a Dynamic Action

I was asked recently how I implemented the deleting of a row in my demo application, so I thought I would post the answer here in case anyone else was curious.

To accomplish the deletion of a row with a prompt to the user for confirmation you will need a hidden page item and a dynamic action.

On the page that has your report, add a hidden page item – mine is called P20_DELETE_ID. This item will be used by our dynamic action to hold the primary key of the row on which the user clicked the delete icon.

You need to add a link column to your report for the delete icon with the following attributes:

Link Target: URL
URL: javascript:void(null);
Link Text: <span class="t-Icon fa fa-trash delete-note" aria-hidden="true"></span>
Link Attributes: data-id=#REMOVE#
Link Column

Notice in the Link Text that I added a class called delete-note. This is the jQuery selector we will use to trigger our dynamic action. Also, notice the Link Attributes – the column referenced here, in my case #REMOVE#, should hold the primary key for the row. This value will be used to identify the row that needs to be deleted in your delete PL/SQL statement.

Next, we need a dynamic action that fires on click of our jQuery selector, .delete-note. This action will have four true actions:
Delete Row Dynamic Action

True Action #1: Confirm
Text: Are you sure?
Confirm

True Action #2: Set Value
Settings:
Set Type: JavaScript Expression
JavaScript Expression: $(this.triggeringElement).parent().data('id')
Affected elements:
Selection Type: Item(s)
Items(s): P20_DELETE_ID <—- your hidden page item
Set Value

True Action #3: Execute PL/SQL Code
PL/SQL Code: delete from jsd_notes where id = :P20_DELETE_ID;
Items to Submit: P20_DELETE_ID <—- your hidden page item
Execute PL/SQL Code

True Action #4: Refresh
Selection Type: Region
Region: Notifications <—- your report region
Refresh

And that should do it 🙂
– Jackie –

Soruce from

Advertisements

How to show and hide inline dialog in oracle apex using JavaScript

How to show and hide inline dialog in oracle apex using JavaScript

  1. Create a Region named as example “Employee Details:
  2. Assign a Static ID of the region “EMPDTLS”  ( ..Region Property/Advanced/Static ID:)
  3. Create a Page Button Named “ShowDialog”
  4. Go to the button property and set it’s properties as below:
  5. Behavior/Action = Redirect to URL
  6. Target = javascript:openModal('EMPDTLS');
  7. Now Save and run the page. when you click “ShowModal” button the modal dialog will be appeared.
  8. Now for closing the Modal dialog, you can add a new button “closeDialog” in the dialog region and set the properties as below:
  9. Behavior/Action = Redirect to URL
  10. Target = javascript:closeModal(‘EMPDTLS’);
  11. If you want to pass value in the Dialog region then

    javascript:$s(‘P1_EMPID’,7369);openModal(‘EMPDTLS’);
    or

    javascript:$s(‘P1_EMPID’,$v(‘P1_EMPNO’));openModal(‘EMPDTLS’);
    or

    javascript:$s(‘P1_EMPID’,’#EMPNO#’);openModal(‘EMPDTLS’);
    or

#EMPNO# – this is applicable when you calling dialog window from Interactive or classic report. here EMPNO is the column name.

 

Source

Select All / Unselect All Checkbox in Interactive Report Header

Select All / Unselect All Checkbox in Interactive Report Header

 

I want a checkbox in an Interactive Report (IR), and I want the users to be able to quickly Select All or Unselect All of them (but only for rows that were rendered on the page). I don’t want two big clunky buttons to do this, I just want a single checkbox in the header like I see on cool peoples’ web sites.

To do this:

1. In the Region Definition for the IR, add the checkbox to the query, e.g.:

SELECT ...,
       apex_item.checkbox(1, record_id) selected
FROM   ...

Also, set the region Static ID to some value, e.g. myreport This will be referred to by the dynamic action.

2. In the Report Attributes for the IR, modify the attributes of column “SELECTED”:

Heading =

<input type="checkbox" id="selectunselectall">

Escape Special Characters = No

Enable Users To = (uncheck all options, including Hide, Sort, etc.)

3. In the page definition, add a Dynamic Action:

Event = Change
Selection Type = jQuery Selector
jQuery Selector = #selectunselectall
Event Scope = Dynamic
Static Container (jQuery Selector) = #myreport

True Action = Execute JavaScript Code
Fire On Page Load = (uncheck)
Code =

if ($('#myreport #selectunselectall' ).is(':checked') ) {
  $('#myreport input[type=checkbox][name=f01]').prop('checked',true);
} else {
  $('#myreport input[type=checkbox][name=f01]').prop('checked',false);
}

The only issue with this is if the user clicks “Action” and “Select Columns”, the checkbox item shows the html code (”

UPDATE 18/5/2017: updated for multiple IRs on same page (APEX 5+)
UPDATE 23/5/2017: updated to recommended prop instead of attr

 

thanks to  : https://jeffkemponoracle.com/2012/11/select-all-unselect-all-checkbox-in-interactive-report-header/

Make input value uppercase in CSS without affecting the placeholder

input { 
    text-transform: uppercase;
}
::-webkit-input-placeholder { /* WebKit browsers */
    text-transform: none;
}
:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
    text-transform: none;
}
::-moz-placeholder { /* Mozilla Firefox 19+ */
    text-transform: none;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
    text-transform: none;
}
::placeholder { /* Recent browsers */
    text-transform: none;
}

How To Convert Number into Words using Oracle SQL Query

How can you convert a number into words using Oracle Sql Query? What I mean by Number to Word is:

12 = Twelve
102 = One Hundred Two
1020 = One Thousand Twenty

Here’s a classy query which will convert number into words.Please see the query below:

select to_char(to_date(:number,'j'),'jsp') from dual;

If I pass 234 in number, then the output will : two hundred thirty-four

SELECT TO_CHAR (TO_DATE (234, 'j'), 'jsp') FROM DUAL;
//Output: two hundred thirty-four

SELECT TO_CHAR (TO_DATE (24834, 'j'), 'jsp') FROM DUAL;
//Output: twenty-four thousand eight hundred thirty-four

SELECT TO_CHAR (TO_DATE (2447834, 'j'), 'jsp') FROM DUAL;
//Output: two million four hundred forty-seven thousand eight hundred thirty-four

So how the query works? Well here’s why:

If you look into the inner most part of the query to_date(:number,'j') the ‘j’ or J is the Julian Date (January 1, 4713 BC), basically this date is been used for astronomical studies.

So to_date(:number,'j') it take the number represented by number and pretend it is a julian date, convert into a date.

If you pass 3 to number, so it will convert date to 3rd Jan 4713 BC, it means 3 is added to the Julian date.

Now to_char(to_date(:number,'j'),'jsp')jsp = Now; take that date(to_date(:number,'j')) and spell the julian number it represents

Limitation & workaround

There is a limitation while using Julian dates ,It ranges from 1 to 5373484. That’s why if you put the values after 5373484, it will throw you an error as shown below:

ORA-01854: julian date must be between 1 and 5373484

To cater the above problem ,create a function,

and with little trick with j->jsp ,you can fetch the desired result.

create or replace FUNCTION spell_number (p_number IN NUMBER)
   RETURN VARCHAR2
AS
   TYPE myArray IS TABLE OF VARCHAR2 (255);

   l_str myArray
         := myArray ('',
                     ' thousand ',
                     ' million ',
                     ' billion ',
                     ' trillion ',
                     ' quadrillion ',
                     ' quintillion ',
                     ' sextillion ',
                     ' septillion ',
                     ' octillion ',
                     ' nonillion ',
                     ' decillion ',
                     ' undecillion ',
                     ' duodecillion ');

   l_num      VARCHAR2 (50) DEFAULT TRUNC (p_number);
   l_return   VARCHAR2 (4000);
   l_pisa     varchar2(50);
BEGIN
   FOR i IN 1 .. l_str.COUNT
   LOOP
      EXIT WHEN l_num IS NULL;

      IF (SUBSTR (l_num, LENGTH (l_num) - 2, 3) <> 0)
      THEN
         l_return :=
            TO_CHAR (TO_DATE (SUBSTR (l_num, LENGTH (l_num) - 2, 3), 'J'),
                     'Jsp')
            || l_str (i)
            || l_return;
      END IF;

      l_num := SUBSTR (l_num, 1, LENGTH (l_num) - 3);
   END LOOP;

    l_pisa := substr(p_number,instr(p_number,'.')+1,length(p_number)-instr(p_number,'.'));
    if instr(p_number,'.') > 0 and l_pisa < 99  then
    l_return := upper(l_return||' and '|| to_char(to_date(l_pisa, 'J'), 'JSP') ||' Paise Only');
    end if;
   RETURN l_return;
END;
/

SELECT spell_number (53734555555585.13) FROM DUAL;

Output:

FIFTY-THREE TRILLION SEVEN HUNDRED THIRTY-FOUR BILLION FIVE HUNDRED FIFTY-FIVE MILLION FIVE HUNDRED FIFTY-FIVE THOUSAND FIVE HUNDRED EIGHTY-FIVE AND THIRTEEN PISA ONLY

How to increase inline dialog size in Oracle APEX Universal Theme

There are three predefined inline dialog sizes in UT.

Sometimes developer needs inline dialog with custom sizes, for example, large than largest of theme predefined. If you use Universal Theme,  the simplest way how to increase inline dialog is to add some css to inline dialog region definition:

In this example 800 is required dialog width in pixels, 540 – height respectively.

Apex – Interactive Report – Hide Column in CSV Download?

You can hide it by putting a condition on the column of type PL/SQL Expression and using the following as the expression:

NVL(:REQUEST,’MY_REQ’) IN(‘CSV’,’XLS’,’PDF’,’XML’,’RTF’,’HTMLD’)

That will check the APEX bind variable “REQUEST”, and if it is CSV, XLS, PDF, XML, RTF or HTML then the column will not be shown!

More info

To stop a column from showing up for an email, you can use the following:

NVL(wwv_flow.g_widget_action, ‘MY_REQ’) != ‘SEND_EMAIL’