You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: powerapps-docs/maker/portals/admin/add-powerbi-report.md
+131-4Lines changed: 131 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,24 +53,151 @@ For example:
53
53
> [!div class=mx-imgBorder]
54
54
> 
55
55
56
-
## Hide the Filters pane in portals web page
56
+
## How to use powerbi-client JavaScript library in portals
57
+
58
+
You can use [powerbi-client JavaScript library](https://github.com/microsoft/PowerBI-JavaScript#powerbi-client) while embedding Power BI reports or dashboards in portals. See [Power BI JavaScript wiki](https://github.com/Microsoft/PowerBI-JavaScript/wiki) for more details.
59
+
60
+
For example, here's a sample JavaScript that can be used to update the report settings, or to handle events. This sample disables filters pane, disables page navigation and enables *dateSelected* event.
61
+
62
+
```javascript
63
+
$(function(){
64
+
var embedContainer =$(".powerbi")[0];
65
+
var report =powerbi.get(embedContainer);
66
+
report.on("loaded", function(){
67
+
report.updateSettings({
68
+
panes: {
69
+
filters :{
70
+
visible:false
71
+
},
72
+
pageNavigation:{
73
+
visible:false
74
+
}
75
+
}
76
+
}).catch(function (errors) {
77
+
console.log(errors);
78
+
});
79
+
})
80
+
report.on('dataSelected', function(event){
81
+
console.log('Event - dataSelected:');
82
+
console.log(event.detail);
83
+
})
84
+
})
85
+
```
86
+
87
+
To add custom JavaScript to a web page:
88
+
89
+
1. Open the [Portal Management](../configure/configure-portal.md) app.
90
+
1. Select **Web Pages** from the left-pane.
91
+
1. Select the web page that contains the Power BI report or dashboard.
92
+
1. Select **Advanced** tab.
93
+
1. Copy and paste the JavaScript inside the **Custom JavaScript** section.
94
+
1. Select **Save & Close**.
95
+
96
+
Let's understand the sample JavaScript operations, and different options.
97
+
98
+
### Get a reference to the embedded report HTML
99
+
100
+
Get a reference to the embedded report HTML.
101
+
102
+
```javascript
103
+
var embedContainer =$(".powerbi")[0];
104
+
```
105
+
106
+
More information: [Get a reference to an existing Power BI component given the containing element](https://github.com/microsoft/PowerBI-JavaScript/wiki/Service-Details#get-a-reference-to-an-existing-power-bi-component-given-the-containing-element)
107
+
108
+
### Get a reference to the embedded report
109
+
110
+
```javascript
111
+
var report =powerbi.get(embedContainer);
112
+
```
113
+
114
+
### Work with Power BI panes
115
+
116
+
You can use the *Panes* related settings to work with Power BI panes on a portals web page. For example, you can use the filters setting to hide or show the pane. Or, use the paging with page navigation setting.
117
+
118
+
Panes can be updated using JavaScript directly as shared in the [previous example](#how-to-use-powerbi-client-javascript-library-in-portals), or you can use HTML with the `<div>` tags.
119
+
120
+
The following samples show how to use both methods, using JavaScript directly, or through HTML.
121
+
122
+
#### Change panes using JavaScript
123
+
124
+
To hide the Filters pane using above JavaScript sample, use the following format.
125
+
126
+
```javascript
127
+
report.updateSettings({
128
+
panes: {
129
+
filters :{
130
+
visible:false
131
+
},
132
+
}
133
+
```
134
+
135
+
Similarly, if you want to work with page navigation in addition to filters:
136
+
137
+
```javascript
138
+
report.updateSettings({
139
+
panes: {
140
+
filters :{
141
+
visible:false
142
+
},
143
+
pageNavigation:{
144
+
visible:false
145
+
}
146
+
}
147
+
```
57
148
58
-
Power BI allows you to [hide the Filters pane](https://docs.microsoft.com/power-bi/create-reports/power-bi-report-filter#hide-the-filters-pane-while-editing) allowing extra space on screen when Filters pane isn't needed. Similarly, you can hide the Filters pane for a dashboard or a report embedded on a web page in your portal. To hide, you can use the [Power BI JavaScript embed configuration](https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details) attribute called `powerbi-settings-filter-pane-enabled` and set its value to `false`.
149
+
More information: [Update settings](https://github.com/Microsoft/PowerBI-JavaScript/wiki/Update-Settings) and [Embed configuration - Settings](https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details#settings)
59
150
60
-
For example, use the following sample code in your web page's [copy (HTML)](../configure/web-page.md#web-page-attributes) attribute to hide Power BI Filters pane in portals.
151
+
#### Change panes using HTML
152
+
153
+
You can also use the attribute called `powerbi-settings-filter-pane-enabled` and set its value to `false` to hide the Filters pane. You can add this sample code in a web page's [copy (HTML)](../configure/web-page.md#web-page-attributes) attribute.
0 commit comments