Monday, 21 January 2008

Tabular form - updating a value in another column Vol. 1

Just recently, I had a requirement from one of my customers to create a kind of a form similar to excel, where user could update particular columns and this update will be applied (calculated) to the other columns, before the form is submitted.

First, I tried the solution posted in the forum, where you need to loop through a table using html_CascadeUpTill and and then find the row position. In some constelations this didn't work (vertical report template). I decided to look for alternate solutions and found out that this can be done in a more transparent way by simply using apex_item package and the ROWNUM. Also, the javascript code you need to do the update is much more transparent and much easier to debug. I also created a validation process to make sure only numbers are entered and an update statement for saving the changes to the corresponding table.

If you want to see a working example, go to my ApEx Demo Appication. There, you will find the full code.






5 comments:

  1. It seems your (great) demo application is gone... I recieve this error :

    application=31517 workspace=232747901357348119


    Error: ERR-1014 Application not found.
    Return to Studio

    ReplyDelete
  2. Roel,

    Read the Login-Page information

    http://htmldb.oracle.com/pls/otn/f?p=31517:1

    Denes Kubicek

    ReplyDelete
  3. Hi Denes!!
    I have to do a similar form but it has to put in a column the value of a difference of two dates, how I have to do the code javascript?

    Thanks a lot!

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. I do something similar to this very often.

    I prefer keeping my sql query simple (no apex_item's) and adding a function to the element attributes field. If you pass the 'this' pointer, you can easily retrieve the name and parse the rownumber, etc within JS. e.g (onChange="f_increase_salary(this)")

    It just makes the code a little easier to read IMHO.

    ReplyDelete