How I can make Mandatory add at least one row in Interactive grid in apex oracle

谁说我不能喝 提交于 2020-04-30 09:08:21

问题


I have two region one form and one interactive grid like a master detail(company and company contact person ) how i can make the interactive grid mandatory ,the user can't submit page ,he/she need add at least one row in interactive grid , I can do that or I need to change the interactive grid to collection and count the row in validation


回答1:


This one is a little tricky because of the way processes and validations work with Interactive Grids (they are executed once per submitted row). To work around this, I'll use a page item and a validation that works with it.

The basic idea of this solution is based on the fact that a new row will not have a primary key value. Here are the steps to reproduce (my example was on page 14, update the following as needed).

  1. Create an Interactive Grid (IG) region. The primary key column should be Query Only (which ensures it's null for new rows).
  2. Create a Hidden page item named P14_NULL_FOUND. Set Type under Server-side Condition to Never so that it never renders on the page.
  3. Create an After Submit (before Validations) process. This process will NOT be associated with the IG so it will only fire once. Set the PL/SQL Code attribute to:

    :P14_NULL_FOUND := 'NO';
    

    That will clear out the value of the page item prior to the next process.

  4. Create another After Submit process that runs just after the previous one. Set Editable Region to the IG. Then set the PL/SQL Code to something like the following:

    if :PK_COLUMN_IN_IG is null
    then
      :P14_NULL_FOUND := 'YES';
    end if;
    

    You'll need to replace ":PK_COLUMN_IN_IG" with the name of the primary key column in the IG, such as ":EMPNO". This process will be run once for each submitted row in the IG. If a null value is found for the primary key column, then that would mean the user added a new row and the value of P14_NULL_FOUND would be set to 'YES'.

  5. Create a new validation. This validation will NOT be associated with the IG so it will only fire once. Set Type to PL/SQL Expression. Set PL/SQL Expression to:

    :P14_NULL_FOUND != 'NO'
    

    Then set Error Message to something relevant.

At this point, you should be able to run the page and verify that the processes and validation are working correctly.



来源:https://stackoverflow.com/questions/59827242/how-i-can-make-mandatory-add-at-least-one-row-in-interactive-grid-in-apex-oracle

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!