Forum Stats

  • 3,741,216 Users
  • 2,248,392 Discussions
  • 7,861,675 Comments

Discussions

how to delete row in interactive report and calendar?

loobixcube
loobixcube Member Posts: 19
edited Aug 14, 2019 12:11PM in APEX Discussions

Hi, I read a bunch of articles but adding a delete feature doesn't seem to work on interactive reports. I was wondering if anyone knows how to or knows an article/post where it explains how to? ALSO, how to delete events on calendar page. Thanks!

loobixcube

Answers

  • Eslam_Elbyaly
    Eslam_Elbyaly Member Posts: 4,194 Silver Trophy
    edited Aug 13, 2019 1:30PM

    This is a working example,

    USER= forhelpPWD= forhelppwdWorkSpace= ESLAM_WSAPP= TESTPAGES= 2
    loobixcubeloobixcube
  • loobixcube
    loobixcube Member Posts: 19
    edited Aug 14, 2019 9:11AM

    Thanks! When I try to execute this code, it comes across a syntax error:

    $(this.triggeringElement).closest('tr').remove();

    Is there anything I need to change about this for my specific case? Like what is 'tr'? Sorry, I don't really know javascript. Thx!

  • loobixcube
    loobixcube Member Posts: 19
    edited Aug 14, 2019 9:42AM

    Also, does this delete function actually delete the row in the table? because every time i reset the application, the row comes back and no changes were made to the actual table. thx!

  • Eslam_Elbyaly
    Eslam_Elbyaly Member Posts: 4,194 Silver Trophy
    edited Aug 14, 2019 9:43AM

    You should read about html table. closest('tr') is the closest table row element with respect to the triggering element.

    It's jquery.

    https://www.w3schools.com/html/html_tables.asp

  • Eslam_Elbyaly
    Eslam_Elbyaly Member Posts: 4,194 Silver Trophy
    edited Aug 14, 2019 9:44AM

    It does not remove the data from the table. Just the UI element. You should be executing a PL/SQL process when you click the link instead of jQuery or javaScript code.

  • Eslam_Elbyaly
    Eslam_Elbyaly Member Posts: 4,194 Silver Trophy
    edited Aug 14, 2019 9:46AM

    Are you trying with Calendar or the IR? Try to inspect the region and see if you have <tr> elements.

    as far as I'm aware, the IR has. But no clue about calendars.

  • Mint-Innit
    Mint-Innit Member Posts: 371 Silver Badge
    edited Aug 14, 2019 10:14AM

    I have done this using information gleaned from a blog post, where clicking on an icon triggers dynamic actions. Whilst I cannot for the life of me find that original post, I've found this one from Jackie Mcilroy which uses exactly the same method, albeit with slightly different icons and triggering elements to the ones I use.

    https://jackiemcilroy.blogspot.com/2018/03/delete-row-of-report-with-dynamic-action.html

    The way it works is exactly the same though. Using a dynamic action, you store a key in a hidden page item when the delete link is clicked. A PL/SQL action then performs the actual delete from the database.

    Cheers.

    loobixcube
  • loobixcube
    loobixcube Member Posts: 19
    edited Aug 14, 2019 10:32AM

    I tried using this method but always come across THE ERROR, ora-01722 invalid number when I try to execute the PLSQL code. I think there's an issue with the hidden column storing the primary id.

    do I have to modify any of the hidden column's characterstics? or is just setting the column to hidden and making sure the name lines up with every other time it's called good enough? thanks

  • loobixcube
    loobixcube Member Posts: 19
    edited Aug 14, 2019 10:36AM
  • loobixcube
    loobixcube Member Posts: 19
    edited Aug 14, 2019 10:40AM

    Right now, just the IR. Your example does work, where it just removes the UI element, thank you. but I do not know how to execute the PL/SQL process when I try to the ID in a hidden value, would you know anything about that?

  • loobixcube
    loobixcube Member Posts: 19
    edited Aug 14, 2019 11:05AM

    So I toyed around with it and set the hidden value as a number field with a default value of 1.

    I then deleted the set value part of the dynamic action so it just skipped to the execute PLSQL code. This time, it worked because

    delete from anothertest where id = :P9_DELETE_ID;

    both the ID and the hidden column were 1. If I try to do this again but with set value, it says the column is the incorrect data type. I tried casting in the PLSQL code but it didn't work. I'm not very familar with javascript (which is what is used to set the value) so I was wondering if you know of another way to set the value or if you could see what is wrong with my javascript. thank you.

    Javascript used to set hidden item to id:

    $(this.triggeringElement).parent().data('id')

  • loobixcube
    loobixcube Member Posts: 19
    edited Aug 14, 2019 11:05AM

    So I toyed around with it and set the hidden value as a number field with a default value of 1.

    I then deleted the set value part of the dynamic action so it just skipped to the execute PLSQL code. This time, it worked because

    delete from anothertest where id = :P9_DELETE_ID;

    both the ID and the hidden column were 1. If I try to do this again but with set value, it says the column is the incorrect data type. I tried casting in the PLSQL code but it didn't work. I'm not very familar with javascript (which is what is used to set the value) so I was wondering if you know of another way to set the value or if you could see what is wrong with my javascript. thank you.

    Javascript used to set hidden item to id:

    $(this.triggeringElement).parent().data('id')

  • loobixcube
    loobixcube Member Posts: 19
    edited Aug 14, 2019 11:34AM

    I have resolved it! I needed to change the link attribute to the primary key column. Thank you both. @Eslam_Elbyaly @Mint-Innit

  • Eslam_Elbyaly
    Eslam_Elbyaly Member Posts: 4,194 Silver Trophy
    edited Aug 14, 2019 12:11PM

    Setting a hidden items value in oracle Apex is not possible unless you hide the item using JavaScript you can hide it on a page load dynamic action. don't forget to put your page item in items to submit attribute of your pl-sql process.

Sign In or Register to comment.