Overview

Server-Side condition is the condition will execute at the time of page initialization. We can set the server-side condition to the page, region, item, button…etc. Based on the server side conditions we can hide or unhide the page, region, or button…etc. Different types of server-side conditions are available in oracle apex. like, Rows return, No Rows return, SQL Expression, PL/SQL Expression and PL/SQL Function Body…etc.

In the Interactive grid we are having the inbuild buttons like save, add row, and delete. We did not have any option to directly add the Server-Side Condition into these buttons.

In this blog we will see how we can add the server side conditions into these buttons by the custom solutions.

Technologies and Tools Used

The following technology has been used to achieve the expected output.

  • Oracle Apex
  • SQL/PL SQL
  • JavaScript

Use Case

Adding Server-side conditions into the interactive grid inbuild button. By the custom solution.

We are having two different ways. The first one is the Edit authorization feature in the interactive grid attributes. The second one is adding the server-side code in the hidden page item and by JavaScript using these items we can enable and disable buttons.

If the server-side condition code, we are going to add does not have any page items in it we can use the Edit authorization feature. Otherwise, we must use the JavaScript method.

This blog explains how to achieve this requirement.

Architecture

If the authorization condition does not have the page item as the input, we can use this.

Using the Edit authorization feature in the interactive grid attributes. We can enable and disable the buttons.

Step 1:

Create the Authorization Schemes using the server-side condition code or whatever condition code we want to add.

Step 2:

Set the created authorization schemes against the button you want to add as below.

If the authorization condition has the page item as the input, we can use this.

Using JavaScript, we can enable and disable the button.

Step 1:

Create hidden page items as below,

Step 2:

Create the process at before header as below and set the page item flag as ‘Y’ if the conditon is satisfied and set flag as ‘N’ if not satisfied.

Step 3:

Add the JavaScript as below at the JavaScript initialization in the interactive grid attribute.

function(config) {

    var $ = apex.jQuery;

    var toolbarData = $.apex.interactiveGrid.copyDefaultToolbar(),

        toolbarGroup = toolbarData.toolbarRemove(“actions3”);

        toolbarGroup = toolbarData.toolbarFind(“actions2”);

    if (apex.item(‘P3_IG_DELETE_ENABLE’).getValue() == ‘Y’) {

        toolbarGroup.controls.push({

            type: “BUTTON”,

            action: “selection-delete”,

            icon: “icon-ig-delete”,

            label: “Delete”,

            iconBeforeLabel: true,

            hot: true,

            id: “custdelete”

        });

    }

    if (apex.item(‘P3_IG_ADD_ROW_ENABLE’).getValue() == ‘Y’) {

       toolbarGroup.controls.push({

            type: “BUTTON”,

            action: “selection-add-row”,

            icon: “icon-ig-add-row”,

            label: “Add Row”,

            iconBeforeLabel: true,

            hot: true,

            id: “custaddrow”

        });

         $(‘[data-action=”selection-add-row”]’).hide();

    }

   config.toolbarData = toolbarData;

   return config;

}

 

Screen Shot

Using the above steps, we can add the server-side condition to the interactive grid buttons by two methods. If the server-side condition you are going to add doesn’t have the page item, then we can use the Authorizations to each button. If it’s having the page items, then we must use the JavaScript method to add server-side conditions.

Out Put:

The Buttons will get enable and disable based on the conditions.

Recommended Posts

Start typing and press Enter to search