Skip to content

Commit c7cba37

Browse files
committed
Merged PR 24475: Merge feature/context_menu_extension to master
1 parent 76bdf80 commit c7cba37

File tree

6 files changed

+219
-33
lines changed

6 files changed

+219
-33
lines changed

demo/package-lock.json

Lines changed: 103 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
"tests"
3131
],
3232
"dependencies": {
33-
"fetch": "^1.0.0",
34-
"es6-promise": "^3.2.2",
3533
"bootstrap": "^3.3.6",
36-
"jquery": "^3.1.0",
37-
"powerbi-client": "^2.3",
34+
"es6-promise": "^3.2.2",
35+
"fetch": "^1.0.0",
3836
"http-server": "^0.9.0",
37+
"jquery": "^3.1.0",
38+
"powerbi-client": "^2.4.1",
3939
"syntaxhighlighter": "4.0.1"
4040
},
4141
"devDependencies": {}

demo/v2-demo/scripts/codesamples.js

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

769868
function _Page_SetActive() {

demo/v2-demo/scripts/step_embed.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ function Report_ExitFullScreen() {
4747
SetCode(_Report_ExitFullScreen);
4848
}
4949

50+
function Report_Extensions_ContextMenu() {
51+
SetCode(_Report_Extensions_ContextMenu);
52+
}
53+
54+
function Report_Extensions_OptionsMenu() {
55+
SetCode(_Report_Extensions_OptionsMenu);
56+
}
57+
5058
// ---- Page Operations ----------------------------------------------------
5159

5260
function Page_SetActive() {

demo/v2-demo/settings_interact.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<li class="" onclick="Report_UpdateSettings()">Update settings</li>
3333
<li class="" onclick="Report_Reload()">Reload</li>
3434
<li class="" onclick="Report_Refresh()">Refresh</li>
35+
<li class="" onclick="Report_Extensions_OptionsMenu()">Extend options menu</li>
36+
<li class="" onclick="Report_Extensions_ContextMenu()">Extend context menu</li>
3537
<li class="" onclick="Report_FullScreen()">Full screen</li>
3638
<li class="" onclick="Report_ExitFullScreen()">Exit full screen</li>
3739
</ul>

0 commit comments

Comments
 (0)