Friday, July 31, 2020

Redirect to another page using a button in Interactive Grid

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",
         hot:true 
    });
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: "New",
            action: function(event, focusElement) {
         apex.navigation.redirect( "f?p=" + $v( "pFlowId" ) + ":6:" + $v( "pInstance" ) );

            }
        } );
    }
   // Assign new toolbar data back to toolbarData configuration property
   options.toolbarData = toolbarData;
 
   // Return the options
   return options;  
   
}



--------------------------

function(config) {  
    let $ = apex.jQuery,  
        toolbarData = $.apex.interactiveGrid.copyDefaultToolbar(), // copy the whole toolbar  
        toolbarGroup = toolbarData.toolbarFind("actions2"); // this is the group with the save button  
          
        ///  
       config.initActions = function( actions ) {  
        // Add new actions, either singularly passing in an actions object as shown here, or in  
        // multiple by passing an array of action objects  
        actions.add( {  
            name: "my-action",  
            action: function( event, focusElement ) {  
          //redirect to page in this application  set your URL accordingly  
            apex.navigation.redirect ( "f?p=&APP_ID.:1:&SESSION.::&DEBUG.:RP::" );  
                /***In case the Url above  is giving you some issues use this one***/  
//            apex.navigation.redirect( "f?p=" + $v( "pFlowId" ) + ":1:" + $v( "pInstance" ) );  
        } );  
    };     
    // add a new "redirect" button  
    toolbarGroup.controls.push({type: "BUTTON",  
                                iconBeforeLabel: true,  
                                hot: true,  
                                label: 'redirect',  
                                action: "my-action"  
                               });  
  
    //store the config  
    config.toolbarData = toolbarData;  
    return config;  
}  

No comments:

Post a Comment