in src/visual.ts [156:228]
public update(options: powerbi.extensibility.visual.VisualUpdateOptions): void {
const dataView: powerbi.DataView = options
&& options.dataViews
&& options && options.dataViews[0];
if (!dataView) {
return;
}
const viewport: powerbi.IViewport = options && options.viewport
? { ...options.viewport }
: { height: 0, width: 0 };
const settings: Settings = (Settings.getDefault() as Settings).parse(dataView);
this.stateService.parse(settings.internalState);
this.converterOptions = {
columnMapping: this.stateService.states.columnMapping.getColumnMapping(),
dataView,
settings,
settingsState: this.stateService.states.settings,
viewMode: options.viewMode,
viewport,
};
const columnSet: IDataRepresentationColumnSet = this.columnSetConverter.convert(this.converterOptions);
this.stateService.states.columnMapping.applyDefaultRows(columnSet[actualValueColumn.name]);
const dataRepresentation: IDataRepresentation = this.dataDirector.convert(this.converterOptions);
const isAdvancedEditModeTurnedOn: boolean = options.editMode === powerbi.EditMode.Advanced
&& dataRepresentation.isDataColumnBasedModel;
if (this.renderOptions
&& this.settingsService
&& this.renderOptions.isAdvancedEditModeTurnedOn === true
&& isAdvancedEditModeTurnedOn === false
) {
/**
* This is a workaround for Edit button issue. This line forces Power BI to update data-model and internal state
* Edit button disappears once we turn this mode on and go back to common mode by clicking Back to Report
*
* Please visit https://pbix.visualstudio.com/DefaultCollection/PaaS/_workitems/edit/21334 to find out more about this issue
*/
this.settingsService.save([{
objectName: "editButtonHack",
properties: {
"_#_apply_a_workaround_for_edit_mode_issue_#_": `${Math.random()}`,
},
selectionId: null,
}]);
}
this.renderOptions = {
columnSet,
data: dataRepresentation,
hyperlinkAdapter: this.hyperlinkAdapter,
isAdvancedEditModeTurnedOn,
settings,
viewport,
};
this.component.render(this.renderOptions);
if (this.stateService.states.settings.hasBeenUpdated
&& (options.viewMode === powerbi.ViewMode.Edit || options.viewMode === powerbi.ViewMode.InFocusEdit)
) {
// We save state once rendering is done to save current series settings because they might be lost after filtering.
this.stateService.save();
}
}