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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
chcacco
Regular Visitor

๐Ÿ”„ Selection Reset When Clicking DataGrid After Filtering in Power BI Custom Visual

Im developing a Power BI Custom Visual using React + TypeScript + MUI DataGrid. The visual correctly applies filtering when selecting a slice in a Pie Chart. However, when I click on a cell in the DataGrid after filtering, Power BI triggers update() and resets the selection, forcing all rows to regenerate.

Can someone point me in the right direction in order to solve this issue?

1 ACCEPTED SOLUTION
Poojara_D12
Super User
Super User

Hi @chcacco 

The issue occurs because Power BI's update() method triggers a full refresh of the custom visual whenever an interaction happens, such as clicking on a cell in the MUI DataGrid. This causes the selection state to reset, leading to all rows regenerating instead of preserving the previous selection. To resolve this, you need to maintain state persistence within React, ensuring that selected rows remain unchanged even when Power BI updates the visual. One way to do this is by using React state hooks (useState) or refs (useRef) to store the selected row IDs before the update occurs. Additionally, using suppressAnimations: true in Power BI's visual API can prevent unnecessary UI resets. Another key approach is to restore the selection state inside update() by reapplying previously stored selections after the visual updates. Furthermore, optimizing the filtering logic ensures that only affected rows change rather than reloading all rows. If needed, integrating Power BI's selectionManager can provide better control over interactions and prevent unwanted state loss when clicking on DataGrid elements.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

View solution in original post

2 REPLIES 2
Poojara_D12
Super User
Super User

Hi @chcacco 

The issue occurs because Power BI's update() method triggers a full refresh of the custom visual whenever an interaction happens, such as clicking on a cell in the MUI DataGrid. This causes the selection state to reset, leading to all rows regenerating instead of preserving the previous selection. To resolve this, you need to maintain state persistence within React, ensuring that selected rows remain unchanged even when Power BI updates the visual. One way to do this is by using React state hooks (useState) or refs (useRef) to store the selected row IDs before the update occurs. Additionally, using suppressAnimations: true in Power BI's visual API can prevent unnecessary UI resets. Another key approach is to restore the selection state inside update() by reapplying previously stored selections after the visual updates. Furthermore, optimizing the filtering logic ensures that only affected rows change rather than reloading all rows. If needed, integrating Power BI's selectionManager can provide better control over interactions and prevent unwanted state loss when clicking on DataGrid elements.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
Anonymous
Not applicable

Hi @chcacco ,

 

If you want to custom visual save states, you might consider checking out the following links:

Solved: Re: Power BI Custom Visual state persistence - Microsoft Fabric Community

PowerBI Desktop Custom Visual - Storage Problem - Stack Overflow

Trick to persist properties of Power BI visuals af... - Microsoft Fabric Community

Make sure you are using the latest version of the software. Sometimes updates contain fixes for such issues.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.