oracle-apexoracle-apex-19.1

item validation is not working properly in oracle apex interactive grid page


I have an interactive grid in APEX page under same region I have created an Item: "P300_ADD_MODIFY_REASON". I want to put a validation for that item, which when I did with a PLSQL expression (:P300_ADD_MODIFY_REASON is not null) and Server side condition in validation for Item is null. It is working when I do modification in report and add reason but it doesn't work if I miss to add reason and do modification later, post then when I add reason it gives error. To resolve it I have do some change in report with added reason then it works. enter image description here

What I understand is, that item which holds value doesn't capture in validation when I try to save page 2nd time. I am sure there should be some other method to put validation on Item as with column I am able to. TIA


Solution

  • The issue is that the "Save" button of the interactive grid is used. That will just cause a submit of the interactive grid region, not a full page submit.

    The fastest workaround is to create an additional button on the page that submits the page and hide the default save button on the IG. This will also submit the interactive grid changes and submit the page item P4_NEW which will then fire the validation.

    To hide the default save button on the interactive grid (since that shouldn't be used), set the IG Region > Attributes > Initialization JavaScript Function to

    function (config)
    {
        var $ = apex.jQuery,
            toolbarData = $.apex.interactiveGrid.copyDefaultToolbar(),
            toolbarGroup = toolbarData.toolbarFind( "actions2" );
    
        //Hide save button
        toolbarGroup.controls.splice(toolbarGroup.controls.indexOf("save"),1);
        config.toolbarData = toolbarData;
    
      return config;
    }
    

    A cleaner solution is to remove the original "Save" button from the interactive grid and add a new "Save" button with a custom action to submit the page. For that use the following Initialization Javascript Function instead of the one above:

    function (config)
    {
        var $ = apex.jQuery,
            toolbarData = $.apex.interactiveGrid.copyDefaultToolbar(),
            toolbarGroup2 = toolbarData.toolbarFind( "actions2" );
    
        //Hide original save button (last array element)
        toolbarGroup2.controls.pop();
    
        // Add new button with page submit action
        toolbarGroup2.controls.push(
            {
                type: "BUTTON",
                label: "Save",
                action: "save",
                //icon: "icon-ig-save",
                iconBeforeLabel: true,
                hot: true,
                action: "custom-ig-save"
            });
    
        config.initActions = function( actions ) {
            actions.add( {
                name: "custom-ig-save",
                action: function(event, focusElement) {
                    apex.submit('SAVE');
                }
            });
        }
    
        config.toolbarData = toolbarData;
    
      return config;
    }