Introduction: –

This document provides guidance on Interactive Grid : Lock/ Unlock Rows. A common scenario involves if You want to create an Interactive Grid where the HR department can update employee details such as name, address, job title, and salary.

However, some records should be locked and not editable. For example, the employees who are terminated or have pending approvals should not be allowed to be edited by mistake. These records must remain intact, while the rest of the records are available for updating.

The following technologies has been used to achieve the same.

  • Oracle APEX
  • Javascript
  • PLSQL

Why we need to do: –

I had a situation to lock and unlock intractive grid rows then I need to do.

How do we solve:

Step:1 – Go to the specific page where your intractive grid and Add the following code to your global functions

Code: Create function using below code

function lockUnlock(pAjaxProcess, pId) {

apex.message.confirm(“Toggle Lock/Unlock?”, function(okPressed) {

if (okPressed) {

apex.server.process(

pAjaxProcess,

{

x01: pId,

},

{

success: function(response) {

var showButton = response.trim();

if (pAjaxProcess === “AtTaskToggleAjax”) {

var atTaskRegion = apex.region(“AtTaskDetailsStaticId”);

if (atTaskRegion) {

atTaskRegion.refresh();

}

}

},

error: function(xhr, status, error) {

console.error(“Error:”, error);

apex.message.alert(“An error occurred while processing your request.”);

},

dataType: “text”,

}

);

}

});

}

Step:2 – Next, place this snippet in ajax callback process.

ddeclare

l_confirm_flag varchar2(1);

l_show_button  varchar2(1);

lv_app number;

begin

 

update emp

set confirm_flag = case

when nvl(confirm_flag, ‘N’) = ‘Y’ then ‘N’

else ‘Y’

end

where empno = APEX_APPLICATION.g_x01;

commit;

 

exception

when others then

— Log errors for debugging

dbms_output.put_line(‘Error: ‘ || sqlerrm);

raise;

end;

Step:3 – Next, go to intractive grid report sql and add below column

, CASE WHEN confirm_flag = ‘Y’ THEN ‘fa-lock’ ELSE ‘fa-unlock’ END STATUS_ICON

Step:4 – Go to column and make as link. And add below code in URL  

URL => javascript:lockUnlock(‘AtTaskToggleAjax’, ‘&EMPNO.’);

Link Text=>  <span class=”fa &STATUS_ICON.” style=”color: grey;”></span>

Screen Shot

Conclusion: 

Implementing Interactive Grid : Lock/ Unlock Rows that appear upon update intractive grid in Oracle APEX is a simple yet effective way to enhance the user experience.

Recommended Posts

Start typing and press Enter to search