@@ -1640,6 +1640,95 @@ function _Bookmarks_ExitPresentation() {
16401640 report . bookmarksManager . play ( models . BookmarksPlayMode . Off ) ;
16411641}
16421642
1643+ function _Visual_GetSlicer ( ) {
1644+ // Get a reference to the embedded report HTML element
1645+ var embedContainer = $ ( '#embedContainer' ) [ 0 ] ;
1646+
1647+ // Get a reference to the embedded report.
1648+ report = powerbi . get ( embedContainer ) ;
1649+
1650+ // Retrieve the page collection and get the visuals for the first page.
1651+ report . getPages ( )
1652+ . then ( function ( pages ) {
1653+ // Retrieve active page.
1654+ var activePage = pages . find ( function ( page ) {
1655+ return page . isActive ;
1656+ } ) ;
1657+
1658+ activePage . getVisuals ( )
1659+ . then ( function ( visuals ) {
1660+ // Retrieve the wanted visual.
1661+ var slicer = visuals . find ( function ( visual ) {
1662+ return visual . type == "slicer" ;
1663+ } ) ;
1664+
1665+ // Get the slicer state which contains the slicer filter.
1666+ slicer . getSlicerState ( )
1667+ . then ( function ( state ) {
1668+ Log . log ( state ) ;
1669+ } )
1670+ . catch ( function ( errors ) {
1671+ Log . log ( errors ) ;
1672+ } ) ;
1673+ } )
1674+ . catch ( function ( errors ) {
1675+ Log . log ( errors ) ;
1676+ } ) ;
1677+ } )
1678+ . catch ( function ( errors ) {
1679+ Log . log ( errors ) ;
1680+ } ) ;
1681+ }
1682+
1683+ function _Visual_SetSlicer ( ) {
1684+ // Build the filter you want to use. For more information, See Constructing
1685+ // Filters in https://github.com/Microsoft/PowerBI-JavaScript/wiki/Filters.
1686+ const filter = {
1687+ $schema : "http://powerbi.com/product/schema#basic" ,
1688+ target : {
1689+ table : "District" ,
1690+ column : "District Manager"
1691+ } ,
1692+ operator : "In" ,
1693+ values : [ "Brad Sutton" , "Andrew Ma" ]
1694+ } ;
1695+
1696+ // Get a reference to the embedded report HTML element
1697+ var embedContainer = $ ( '#embedContainer' ) [ 0 ] ;
1698+
1699+ // Get a reference to the embedded report.
1700+ report = powerbi . get ( embedContainer ) ;
1701+
1702+ // Retrieve the page collection and get the visuals for the first page.
1703+ report . getPages ( )
1704+ . then ( function ( pages ) {
1705+ // Retrieve active page.
1706+ var activePage = pages . find ( function ( page ) {
1707+ return page . isActive ;
1708+ } ) ;
1709+
1710+ activePage . getVisuals ( )
1711+ . then ( function ( visuals ) {
1712+ // Retrieve the wanted visual.
1713+ var slicer = visuals . find ( function ( visual ) {
1714+ return visual . type == "slicer" ;
1715+ } ) ;
1716+
1717+ // Set the slicer state which contains the slicer filters.
1718+ slicer . setSlicerState ( { filters : [ filter ] } )
1719+ . catch ( function ( errors ) {
1720+ Log . log ( errors ) ;
1721+ } ) ;
1722+ } )
1723+ . catch ( function ( errors ) {
1724+ Log . log ( errors ) ;
1725+ } ) ;
1726+ } )
1727+ . catch ( function ( errors ) {
1728+ Log . log ( errors ) ;
1729+ } ) ;
1730+ }
1731+
16431732function _Visual_SetFilters ( ) {
16441733 // Build the filter you want to use. For more information, See Constructing
16451734 // Filters in https://github.com/Microsoft/PowerBI-JavaScript/wiki/Filters.
0 commit comments