<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Getting drill-through to work for a table visual in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Getting-drill-through-to-work-for-a-table-visual/m-p/3030898#M6598</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on a custom visual based on table data, and I want to add drill-through capabilities to it.&lt;/P&gt;&lt;P&gt;I know it should be possible since it is mentioned multiple times on this forum,&lt;BR /&gt;and explicitly stated here:&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Custom-Visuals-Ideas/Enable-drill-through-on-Custom-Visuals/idc-p/584218/highlight/true#M285" target="_blank"&gt;Enable drill through on Custom Visuals - Microsoft Power BI Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, following all examples I can find, I still cannot get it to work.&lt;/P&gt;&lt;P&gt;The context menu is showing. I can include/exclude and all of that, but I never see the option to drill through.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I convert the visual to a PowerBI exTable visual, then it is working. So it is not something wrong with my report.&lt;/P&gt;&lt;P&gt;I know the context menu is working since I can filter with it.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="emileklund_1-1674124437739.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/858207iD55F9820161D4F68/image-size/medium?v=v2&amp;amp;px=400" role="button" title="emileklund_1-1674124437739.png" alt="emileklund_1-1674124437739.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I still missing? Below is a minimal repro of my code in a project created by running "npx powerbi-visuals-tools new tableDrillThrough".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export class Visual implements IVisual {
    private readonly host: powerbi.extensibility.visual.IVisualHost;
    private readonly table: HTMLTableElement;
    private readonly selectionManager: powerbi.extensibility.ISelectionManager;

    constructor(options: VisualConstructorOptions) {
        this.host = options.host;
        this.selectionManager = this.host.createSelectionManager();

        if (document) {
            this.table = document.createElement("table");
            options.element.appendChild(this.table);
        }
    }

    public update(options: VisualUpdateOptions) {
        const dataview = options.dataViews.at(0);

        if (dataview == null || dataview.table == null) {
            return;
        }

        const rowNodes = [];

        const headerRow = document.createElement("tr");
        for (const column of dataview.table.columns) {
            const headerCell = document.createElement("th");
            headerCell.textContent = column.displayName;
            headerRow.appendChild(headerCell);
        }

        rowNodes.push(headerRow);

        for (let rowIndex = 0; rowIndex &amp;lt; dataview.table.rows.length; rowIndex++) {
            const row = dataview.table.rows[rowIndex];
            const rowElement = document.createElement("tr");

            for (const item of row) {
                const valueCell = document.createElement("td");
                valueCell.textContent = String(item);
                rowElement.appendChild(valueCell);
            }
            
            const selectionId = this.host.createSelectionIdBuilder()
                .withTable(dataview.table, rowIndex)
                .createSelectionId();

            rowElement.addEventListener("contextmenu", (event) =&amp;gt; {
                this.selectionManager.showContextMenu(
                    selectionId,
                    { x: event.x, y: event.y },
                    "values" // Not sure what this should be, does not seem to make a difference
                );

                // Prevent the browser context-menu from showing
                event.preventDefault();
                return false;
            })

            rowNodes.push(rowElement);
        }

        this.table.replaceChildren(...rowNodes)
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;Ofcourse I also edited the capabilities to have a table-like dataview mapping:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "dataRoles": [
        {
            "displayName": "Values",
            "name": "values",
            "kind": "GroupingOrMeasure"
        }
    ],
    "dataViewMappings": [
        {
            "table": {
                "rows": {
                    "select": [
                        {
                            "for": {
                                "in": "values"
                            }
                        }
                    ],
                    "dataReductionAlgorithm": {
                        "window": {
                            "count": 30000
                        }
                    }
                }
            }
        }
    ],
    "privileges": []
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jan 2023 10:34:59 GMT</pubDate>
    <dc:creator>emil-eklund</dc:creator>
    <dc:date>2023-01-19T10:34:59Z</dc:date>
    <item>
      <title>Getting drill-through to work for a table visual</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Getting-drill-through-to-work-for-a-table-visual/m-p/3030898#M6598</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on a custom visual based on table data, and I want to add drill-through capabilities to it.&lt;/P&gt;&lt;P&gt;I know it should be possible since it is mentioned multiple times on this forum,&lt;BR /&gt;and explicitly stated here:&amp;nbsp;&lt;A href="https://community.powerbi.com/t5/Custom-Visuals-Ideas/Enable-drill-through-on-Custom-Visuals/idc-p/584218/highlight/true#M285" target="_blank"&gt;Enable drill through on Custom Visuals - Microsoft Power BI Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, following all examples I can find, I still cannot get it to work.&lt;/P&gt;&lt;P&gt;The context menu is showing. I can include/exclude and all of that, but I never see the option to drill through.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I convert the visual to a PowerBI exTable visual, then it is working. So it is not something wrong with my report.&lt;/P&gt;&lt;P&gt;I know the context menu is working since I can filter with it.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="emileklund_1-1674124437739.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/858207iD55F9820161D4F68/image-size/medium?v=v2&amp;amp;px=400" role="button" title="emileklund_1-1674124437739.png" alt="emileklund_1-1674124437739.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What am I still missing? Below is a minimal repro of my code in a project created by running "npx powerbi-visuals-tools new tableDrillThrough".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;export class Visual implements IVisual {
    private readonly host: powerbi.extensibility.visual.IVisualHost;
    private readonly table: HTMLTableElement;
    private readonly selectionManager: powerbi.extensibility.ISelectionManager;

    constructor(options: VisualConstructorOptions) {
        this.host = options.host;
        this.selectionManager = this.host.createSelectionManager();

        if (document) {
            this.table = document.createElement("table");
            options.element.appendChild(this.table);
        }
    }

    public update(options: VisualUpdateOptions) {
        const dataview = options.dataViews.at(0);

        if (dataview == null || dataview.table == null) {
            return;
        }

        const rowNodes = [];

        const headerRow = document.createElement("tr");
        for (const column of dataview.table.columns) {
            const headerCell = document.createElement("th");
            headerCell.textContent = column.displayName;
            headerRow.appendChild(headerCell);
        }

        rowNodes.push(headerRow);

        for (let rowIndex = 0; rowIndex &amp;lt; dataview.table.rows.length; rowIndex++) {
            const row = dataview.table.rows[rowIndex];
            const rowElement = document.createElement("tr");

            for (const item of row) {
                const valueCell = document.createElement("td");
                valueCell.textContent = String(item);
                rowElement.appendChild(valueCell);
            }
            
            const selectionId = this.host.createSelectionIdBuilder()
                .withTable(dataview.table, rowIndex)
                .createSelectionId();

            rowElement.addEventListener("contextmenu", (event) =&amp;gt; {
                this.selectionManager.showContextMenu(
                    selectionId,
                    { x: event.x, y: event.y },
                    "values" // Not sure what this should be, does not seem to make a difference
                );

                // Prevent the browser context-menu from showing
                event.preventDefault();
                return false;
            })

            rowNodes.push(rowElement);
        }

        this.table.replaceChildren(...rowNodes)
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;Ofcourse I also edited the capabilities to have a table-like dataview mapping:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "dataRoles": [
        {
            "displayName": "Values",
            "name": "values",
            "kind": "GroupingOrMeasure"
        }
    ],
    "dataViewMappings": [
        {
            "table": {
                "rows": {
                    "select": [
                        {
                            "for": {
                                "in": "values"
                            }
                        }
                    ],
                    "dataReductionAlgorithm": {
                        "window": {
                            "count": 30000
                        }
                    }
                }
            }
        }
    ],
    "privileges": []
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2023 10:34:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Getting-drill-through-to-work-for-a-table-visual/m-p/3030898#M6598</guid>
      <dc:creator>emil-eklund</dc:creator>
      <dc:date>2023-01-19T10:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Getting drill-through to work for a table visual</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Getting-drill-through-to-work-for-a-table-visual/m-p/3033994#M6616</link>
      <description>&lt;P&gt;Here is the minimal repro on github if it makes it easier:&amp;nbsp;&lt;A href="https://github.com/emil-eklund/tableDrillThrough" target="_blank"&gt;emil-eklund/tableDrillThrough (github.com)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jan 2023 13:08:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Getting-drill-through-to-work-for-a-table-visual/m-p/3033994#M6616</guid>
      <dc:creator>emil-eklund</dc:creator>
      <dc:date>2023-01-20T13:08:08Z</dc:date>
    </item>
  </channel>
</rss>

