@@ -764,6 +764,105 @@ function _Report_saveAs() {
764764 report . saveAs ( saveAsParameters ) ;
765765}
766766
767+ function _Report_Extensions_OptionsMenu ( ) {
768+ const base64Icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAu9JREFUeJzt3U9OE2Ech/FnSiKsXbh340pg5Qk8gofAY3gGtBqWXsKNIR5BF0ZkQ9h6A2pC62LAEP5ITdv3R+f7fJJ3QUh4ZzpPmaaZmReGZxf4ABwDE2C24Jhc/K33wE7D/dB/2gIOgCmLH/S7xhQYA5uN9klz2gK+sLoDf30cXsypB+KAdgf/coyb7Jnutctq/+3/63Sw3WD/VmpUvQFL8BroCubtgL2CeXXNMe3f/ZfjqMH+rVTFO2fZJsCjwrnX+sPgEAKYFc+/1q/hED4DaAEGEM4AwhlAOAMIZwDhDCCcAYQzgHAGEM4AwhlAOAMIZwDhDCCcAYQzgHAGEM4AwhlAOAMIZwDhDCCcAYQzgHAGEM4AwhlAOAMIZwDhDCCcAYQzgHAGEM4AwhlAOAMIZwDhDCDcbQEs+3n7qx7Vqvf/vjH3egctnrfvqB13rnfQ+nn7jtrxd72DDXpj4BVK8RR4DHzq6M/5X1nzZ97qv82A3Q3gDfCidltUoAOmHf0nxGfFG6MaPztqn7evWpOO/lygUH4TGM4AwhlAOAMIZwDhDCCcAYQzgHAGEM4AwhlAOAMIZwDhDCCcAYQbAb+rN0JlJiPgtHorVOZkRH+NuDIddvS3C33Dy8LTTLm4LPwX8AQvDU/zDvh4+cMm/amg+pYlR5vxmVuuBN+iv0XMm0OHO86Bfa4c/NvO+9vAHvCS/h6yG3eSaq1MgBP6//AHwPervxzCB79Z8fxr/Rr6TWA4AwhnAOEMIJwBhDOAcAYQzgDCGUA4AwhnAOEMIJwBhDOAcAYQzgDCGUA4AwhnAOEMIJwBhDOAcAYQzgDCGUA4AwhnAOEMIJwBhDOAcAYQzgDCGUA4AwhnAOEMIJwBhDOAcAYQbggBVK53MCmceymGEMBp4dwnhXMvxRACqFzvwLUWHoAdah5wfQ48b7B/msOY9gHsN9kzzaX1ege3Pm9ftVqsd3Djeft6eLbpl0M5As5Y/KCfAT+AtwzwnP8HNwiKJyPkCoYAAAAASUVORK5CYII=" ;
769+
770+ // The new settings that you want to apply to the report.
771+ const newSettings = {
772+ extensions : [
773+ {
774+ command : {
775+ name : "extension command" ,
776+ title : "Extend commands" ,
777+ icon : base64Icon ,
778+ extend : {
779+ // Define visualOptionsMenu to extend options menu
780+ visualOptionsMenu : {
781+ // Define title to override default title.
782+ // You can override default icon as well.
783+ title : "Extend options menu" ,
784+ }
785+ }
786+ }
787+ }
788+ ]
789+ } ;
790+
791+ // Get a reference to the embedded report HTML element
792+ var embedContainer = $ ( '#embedContainer' ) [ 0 ] ;
793+
794+ // Get a reference to the embedded report.
795+ report = powerbi . get ( embedContainer ) ;
796+
797+ // Update the settings by passing in the new settings you have configured.
798+ report . updateSettings ( newSettings )
799+ . then ( function ( result ) {
800+ $ ( "#result" ) . html ( result ) ;
801+ } )
802+ . catch ( function ( error ) {
803+ $ ( "#result" ) . html ( error ) ;
804+ } ) ;
805+
806+ // Report.on will add an event handler to commandTriggered event which prints to console window.
807+ report . on ( "commandTriggered" , function ( event ) {
808+ var commandDetails = event . detail ;
809+ Log . log ( commandDetails ) ;
810+ } ) ;
811+
812+ // Select Run and open options menu to see new added items.
813+ // Click on menu items added and you should see an entry in the Log window.
814+
815+ Log . logText ( "Open visual options menu by clicking the three dots icon and click on added items to see events in Log window." ) ;
816+ }
817+
818+ function _Report_Extensions_ContextMenu ( ) {
819+ // The new settings that you want to apply to the report.
820+ const newSettings = {
821+ extensions : [
822+ {
823+ command : {
824+ name : "extension command" ,
825+ title : "Extend command" ,
826+ extend : {
827+ // Define visualContextMenu to extend context menu.
828+ visualContextMenu : {
829+ // Define title to override default title.
830+ //You can override default icon as well.
831+ title : "Extend context menu" ,
832+ }
833+ }
834+ }
835+ }
836+ ]
837+ } ;
838+
839+ // Get a reference to the embedded report HTML element
840+ var embedContainer = $ ( '#embedContainer' ) [ 0 ] ;
841+
842+ // Get a reference to the embedded report.
843+ report = powerbi . get ( embedContainer ) ;
844+
845+ // Update the settings by passing in the new settings you have configured.
846+ report . updateSettings ( newSettings )
847+ . then ( function ( result ) {
848+ $ ( "#result" ) . html ( result ) ;
849+ } )
850+ . catch ( function ( error ) {
851+ $ ( "#result" ) . html ( error ) ;
852+ } ) ;
853+
854+ // Report.on will add an event handler to commandTriggered event which prints to console window.
855+ report . on ( "commandTriggered" , function ( event ) {
856+ var commandDetails = event . detail ;
857+ Log . log ( commandDetails ) ;
858+ } ) ;
859+
860+ // Select Run and context menu (i.e. by right click on data points) to see new added items.
861+ // Click on menu items added and you should see an entry in the Log window.
862+
863+ Log . logText ( "Open visual context menu by right click on data points and click on added items to see events in Log window." ) ;
864+ }
865+
767866// ---- Page Operations ----------------------------------------------------
768867
769868function _Page_SetActive ( ) {
0 commit comments