Friday, July 24, 2020

Customizing Interactive Grid Action Menu



add below script in  js path: Interactive Grid (Region Type) --> Attributes --> JavaScript Initialization Code

function(config)
{
    config.initActions = function( actions )
{
actions.remove("show-columns-dialog"); // Hides Columns
        actions.remove("show-filter-dialog"); // Hides Filter


//actions.hide("show-sort-dialog"); // Hides Sort inside "Data"
actions.hide("show-aggregate-dialog"); // Hides Aggregate inside "Data"
actions.hide("refresh"); // Hides Refresh inside "Data"

actions.hide("chart-view"); // Hides Chart.

actions.hide("show-save-report-as-dialog"); // Hides save as inside "Report"
actions.hide("show-edit-report-dialog"); // Hides edit inside "Report"

actions.remove("show-help-dialog"); // Hides Help
    }

config.features.flashback = false; // Hides Refresh inside "Flashback"

   var $ = apex.jQuery;
   var toolbarData = $.apex.interactiveGrid.copyDefaultToolbar();
   config.toolbarData = toolbarData;
   toolbarData[3].controls[0].menu.items[4]['hide'] = true; // Hides Format
   toolbarData[3].controls[0].menu.items[5]['hide'] = true; // Hides Selection
   toolbarData[3].controls[0].menu.items[8]['hide'] = true; // Hides Report

   return config;
}



--- to move options (Download and Sort) to right side of title bar
Region --> Attributes --> JavaScript Initialization Code

function( options )
{
   var $ = apex.jQuery,
       toolbarData = $.apex.interactiveGrid.copyDefaultToolbar(), // Make a copy of the default toolbar
       actionsMenuGroup = toolbarData.toolbarFind( "actions1" );  // Locate the actions menu group

   // Array position denotes displayed position in the toolbar, so let's add the new download button directly
   // after the actions menu group in the array, such that it displays directly after the actions menu in the
   // toolbar.
   // Note: The toolbar is action-driven, so integrates easily with the Interactive Grid. To show the dialog, we
   // just define the appropriate action for showing the download dialog (show-download-dialog).
   actionsMenuGroup.controls.push( {
       type: "BUTTON",
       action: "show-download-dialog",
       iconBeforeLabel: true
   } );
   actionsMenuGroup.controls.push( {
       type: "BUTTON",
       action: "show-sort-dialog",
       iconBeforeLabel: true
   } );
 
   // Assign new toolbar data back to toolbarData configuration property
   options.toolbarData = toolbarData;
 
   // Return the options
   return options;
}


-- adding hello button to beside Reset button

function(config) {
    var $ = apex.jQuery,
        toolbarData = $.apex.interactiveGrid.copyDefaultToolbar(),
        toolbarGroup = toolbarData[toolbarData.length - 1]; // this is the last group with reset button

    // add our own button
    toolbarGroup.controls.push( {
        type: "BUTTON",
        action: "my-action"
    });
    config.toolbarData = toolbarData;

    config.initActions = function( actions ) {
        // can modify state of existing actions or add your own
        // can also pass in an array of actions to add
        actions.add( {
            name: "my-action",
            label: "Hello",
            action: function(event, focusElement) {
                alert("Hello World!");
            }
        } );
    }
    return config;
}

-- combining action menu and tool bar

function( options )
{
   var $ = apex.jQuery,
       toolbarData = $.apex.interactiveGrid.copyDefaultToolbar(), // Make a copy of the default toolbar
       actionsMenuGroup = toolbarData.toolbarFind( "actions1" );  // Locate the actions menu group

   // Array position denotes displayed position in the toolbar, so let's add the new download button directly
   // after the actions menu group in the array, such that it displays directly after the actions menu in the
   // toolbar.
   // Note: The toolbar is action-driven, so integrates easily with the Interactive Grid. To show the dialog, we
   // just define the appropriate action for showing the download dialog (show-download-dialog).
   actionsMenuGroup.controls.push( {
       type: "BUTTON",
       action: "show-download-dialog",
       iconBeforeLabel: true
   } );
   actionsMenuGroup.controls.push( {
       type: "BUTTON",
       action: "show-sort-dialog",
       iconBeforeLabel: true
   } );
 
 toolbarGroup = toolbarData[toolbarData.length - 1]; // this is the last group with reset button
   // add our own button
    toolbarGroup.controls.push( {
        type: "BUTTON",
        action: "my-action"
    });
options.initActions = function( actions ) {
        // can modify state of existing actions or add your own
        // can also pass in an array of actions to add
        actions.add( {
            name: "my-action",
            label: "Hello",
            action: function(event, focusElement) {
                alert("Hello World!");
            }
        } );
    }
   // Assign new toolbar data back to toolbarData configuration property
   options.toolbarData = toolbarData;
 
   // Return the options
   return options;  
   
}

2 comments:

Delete Row Button to all records of Interactive Report in Oracle Apex

 1. add 'Delete' Del column to Report Query 2. Set the Following Properties for the DEL Column Type: Link Heading: Delete Targ...