Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

matrix selection error on other visual

hi power bi community

 

i try create selection with my matrix custom visual, but that make error on other visual

this is my transform, using builder withMatrixNode

 

function visualTransform(options: VisualUpdateOptions, host: IVisualHost): DataViewModel {

    let dataViews = options.dataViews[0];
    var rows = dataViews.matrix.rows;
    let listSelectionId: DataListSelection[] = [];
    let selectionIdBuilder = host.createSelectionIdBuilder();

    rows.root.children.forEach(x => {
        listSelectionId.push({
            value: x.value,
            selectionId: selectionIdBuilder.withMatrixNode(x, rows.levels).createSelectionId()
        });

        if (x.children)
            x.children.forEach(z => {
                listSelectionId.push({
                    value: z.value,
                    selectionId: selectionIdBuilder.withMatrixNode(z, rows.levels).createSelectionId()
                });
                if (z.children)
                    z.children.forEach(a => {
                        listSelectionId.push({
                            value: a.value,
                            selectionId: selectionIdBuilder.withMatrixNode(a, rows.levels).createSelectionId()
                        });

                    })
            })
    });
    return {
        dataPoints: listSelectionId
    }
}

I'm already add click listener to get selection Id and make it selected in manager, and this is the console log

 

c-selection.PNG

 

but but my page always got error in other visual:

c-selection-2.PNG

 

what wrong with my selection code?

 

and one more question, I'm already declare selectcallback in my manager but never called when other visual make selection

        this.selectionManager = this.host.createSelectionManager();
        console.log('constructor allow interaction', this.host.allowInteractions);
        this.selectionManager.registerOnSelectCallback(() => {
            console.log('selection manager callback', this.selectionManager.getSelectionIds());
        });
        this.selectionIdBuilder = options.host.createSelectionIdBuilder();

please help, I'm already strugling with this for 3 days

1 ACCEPTED SOLUTION
Anonymous
Not applicable

finnally I'm solve this

 

thank's to @dm-p  ae https://community.powerbi.com/t5/Developer/Custom-Visual-Selection/m-p/746946#M20083

 

I'm remove the let builder definition and everything work properly

View solution in original post

1 REPLY 1
Anonymous
Not applicable

finnally I'm solve this

 

thank's to @dm-p  ae https://community.powerbi.com/t5/Developer/Custom-Visual-Selection/m-p/746946#M20083

 

I'm remove the let builder definition and everything work properly

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.