cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

[Custom Visual] Boolean Object Properties Auto Exclusive

Hi All,

 

I cannot find a solution on google or docuementation.

 

Is it possible to have these 2 or more properties be auto exclusive? So that once I select one of them, the other will be set as false (off) automatically?

 

Capture.PNG

 

So setting the value from code side, once I will find one true, I will set the others to false.

 

Thanks,

1 ACCEPTED SOLUTION

If you are using a settings class based on DataViewObjectsParser from the powerbi-visuals-utils-dataviewutils helper module, you can just alter the properties of that class.

 

 

// settings.ts
import { dataViewObjectsParser } from "powerbi-visuals-utils-dataviewutils";

import DataViewObjectsParser = dataViewObjectsParser.DataViewObjectsParser;

export class VisualSettings extends DataViewObjectsParser {
  ...
}

// visuals.ts
public update(options: VisualUpdateOptions) {
  this.settings = <VisualSettings>VisualSettings.parse(options && options.dataViews && options.dataViews[0]);
  this.settings.boolean2 = !this.settings.boolean1;
  ...
}

 

-JP

 

View solution in original post

3 REPLIES 3
MVP

You can change the settings of the propety pane directly via your code, so in your case to toggle one boolean based in the status of the other.

I doubt if two toggles that interact which each are that userfriendly. Can't you use a more generic toggle or a dropdown?

 

-JP

Frequent Visitor

So can I change the value assigning it directly via the options.dataview object in the update method? Or should I use a setter function?

About the user interface yes, I know, but I need a visual that only my team will use and it is a super custom visual.

Thanks!!

If you are using a settings class based on DataViewObjectsParser from the powerbi-visuals-utils-dataviewutils helper module, you can just alter the properties of that class.

 

 

// settings.ts
import { dataViewObjectsParser } from "powerbi-visuals-utils-dataviewutils";

import DataViewObjectsParser = dataViewObjectsParser.DataViewObjectsParser;

export class VisualSettings extends DataViewObjectsParser {
  ...
}

// visuals.ts
public update(options: VisualUpdateOptions) {
  this.settings = <VisualSettings>VisualSettings.parse(options && options.dataViews && options.dataViews[0]);
  this.settings.boolean2 = !this.settings.boolean1;
  ...
}

 

-JP

 

View solution in original post

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.