Imrul
Imrul

Reputation: 3516

How to display a report row in a form view as readonly in oracle apex

I have a apex report that has many rows with various data type. Now the user wants to view each row in detail. For this they want it to be in a form view.

But the form view must be conditionally read only (so that the user can not change anything if he does not have privilege).

I have found that , the interactive report of oracle generates a similar view for "single row view" ( although it is not conditionally editable).

In Another word, I want to show the row of a report by pivoting column to row.

Please help me how to do it.

(Creating a new form view and then make each element read only is a option , but it has many problem and is not suitable for over 50 reports.)

Thanks in advance for your help.

Upvotes: 2

Views: 5172

Answers (1)

Tom
Tom

Reputation: 7028

I'd say your only option is to create the form pages, especially when you want editing. IR's don't have that kind of functionality built-in, and if you were to try and give them it through the apex_item API, you'd still have to write custom processes.
It would have been fastest to create the report+form combo upon creation (select form for new page, then form with report).
Now you'd have to select the query for your IR, and use this as a basis for your form query.
To make your items conditionally read-only, you can use the read-only condition on the items. If you use a plsql function returning boolean, you can even test an authorization scheme through apex_util.public_check_authorization (doc: APEX_UTIL)
And other than this route being grievously annoying and time-consuming, i don't know of these 'many problems' with it.


Now, if your form has to be conditionally read-only as a whole and not just certain items, you can solve it in other ways aswell.
For both you'll have to create the form pages: there is no way around this, and is the fastest and easiest.

  1. conditional javascript+conditional process on form pages:

    • dynamic action, fire on page load. Execute javascript:

      $('input').prop('readonly', true);
      

      This will set all input items as readonly.

    • By using CSS you can make this clear to your users, for example

      input[readonly]{ background-color: grey; }
      

    They'll still be able to navigate and see a cursor, but won't be able to directly edit. Of course, javascript is not enough. Someone can still alter values through using a tool like firebug or ie developer tools. To stop that, change the conditions and/or authorization checks on both your dynamic action (only fire when user has no rights) and your record processing process (only run when user has rights). When a user has no rights, and manages to alter values and submit them, nothing will be sent to the database.

  2. conditional link + form page:

    • Set the default link column of your report to show the report detail view.
    • Create another link column on your report, which will link to your form page.
    • Set the display condition or authorization of the second link column to only show when the user is authorized to do so.
    • To prevent non-authorized users from going to said page and manipulate the url to alter values of a record, you'll have to set an authorization scheme to the page though. Or the processes, whatever floats your boat really. Or use session-state protection. (good time to read up on security i guess!)

Upvotes: 2

Related Questions