I have a PBI report that I embed on our web app using the https://www.npmjs.com/package/powerbi-client-react package. In our report we have various visuals and we have registered for handling various events including data selection events for the visuals which works for all the visuals except the slicer visual for some reason.
My question is how I can get the data selected event to work for slicers or is there is a known existing gap on this?
I'm currently using: powerbi-client-react version 1.3.1 which is latest as of time of this writing and is built on top of the powerbi-client package. I also left a snipped of the events I registered for.
As a side note I've followed the events on https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/handle-events and didn't see any other events that made as much sense to use for slicers specifically.
const pbiEventHandlers = new Map([
['loaded', onPbiLoaded],
['rendered', onPbiRendered],
['pageChanged', onPbiPageChange],
['dataSelected', onPbiDataSelected],
['error', onPbiError]
]);
The slicer that is being selected does not have a data point thus, dataSelected event is not getting triggered.
However this is not true for all types of slicer.
Take example of a different slicer:
Slicer with dataSelected event handler
Here, when clicking on "East" dataSelected event is triggered as it does have a data point.
The work around which can be used for these types of slicer would be using visualClicked event with getSlicersStates.
// report.on will add an event listener.
report.on("visualClicked", async function () {
console.log("Visual clicked event triggred");
// Get pages
const pages = await report.getPages();
// Retrieve the page that contain the slicer. For the sample report it will be the active page
let pageWithSlicer = pages.filter(function (page) {
return page.isActive;
})[0];
// Get visuals present on the active page
const visuals = await pageWithSlicer.getVisuals();
// Retrieve the target visual.
let slicer = visuals.filter(function (visual) {
return visual.type === "slicer" && visual.name === "4d55baaa5eddde4cdf90";
})[0];
// Get the slicer state
const state = await slicer.getSlicerState();
console.log(state);
});
Output:
Output for code snippet
Related
I have multiple File Browser Item fields on one page of Application in Oracle Apex.
What happens: When I miss any Item for which validation error fires, I want to hold that file to the browser but I usually loose it if I get that validation error. Is there a solution for the same like other Items fields hold previous value except File Browser Item field. Please see below ss:
Anshul,
APEX 4.2 is very old and no longer supported. A later (or preferably latest) version of APEX will behave differently as Dan explained above.
Can you import your application into apex.oracle.com (which is running APEX 20.1) and you will probably see better results. Based on this you can hopefully use it as justification to upgrade your environment.
Regards,
David
Go to your page-level attributes and a function like the following in the Function and Global Variable Declaration:
function validateItems(request) {
var $file1 = $('#P68_FILE_1');
var $file2 = $('#P68_FILE_2');
var errorsFound = false;
if ($file1.val() === '') {
errorsFound = true;
// Show item in error state
}
if ($file2.val() === '') {
errorsFound = true;
// Show item in error state
}
if (!errorsFound) {
// I think doSubmit was the name of the function back then. If not, try apex.submit
doSubmit(request);
} else {
// Show error message at top of page, I'll use a generic alert for now
alert('You must select a file for each file selector.');
}
}
Then, right-click the Create button and select Create a Dynamic Action. Set the name of the Dynamic Action to Create button clicked.
For the Action, set Type to Execute JavaScript Code. Enter the following JS in code:
validateItems('CREATE');
Finally, ensure that Fire on Initialization is disabled.
Repeat the process for the Save button, but change the request value passed to validateItems to SAVE.
I have a tabular form attribute which is a select list with static values Yes/no and another 2 attributes of Date and display.
My requirement is when i select "No" from the Select List, Date attribute should be enabled and Display attribute should be Disabled and If "Yes" From select list Display attribute should be enabled and Date attribute should be Disabled.
Dynamic Action:
Created a Dynamic action:
event = Change
Selection Type = Jquery selector
Jquery selector = `select[name='f06']`
Action = Execute javascript Code
var el = this.triggeringElement.id;
var row = el.split("_")[1];
if ($v(el) == "N") {
// disable the field
$x_disableItem("f04_" + row, true);
}
else {
// enable the field
$x_disableItem("f04_" + row, false);
}
Dynamic action Working perfectly for already created Rows, But not while i am trying to add new Row by selecting Add row.
https://apex.oracle.com/pls/apex/f?p=38210:LOGIN_DESKTOP:115699939041356
App 38210. Apex 4.2.6
Workspace/username/password : nani4850
Kindly help me out experts!!
Adding a blank row involves a partial page refresh, so the Event Scope of your dynamic action needs to be changed from Static to Dynamic in order for the change event handler to remain bound to the triggering elements.
You'll now find you have problems submitting new records, but if you're having difficulty, that's for another question!
I want to store the configuration of multiple GoogleCharts in a database and use them to create a dashboard of charts.
I currently store the options I supply for each chart in the database and have my dashboard working, displaying multiple charts.
I want to use the ChartEditor class to allow a user to amend a chart and then save the changes back to my database, so that the next time the dashboard is created, the changes are persisted.
Hence, when a user clicks on the OK button on the ChartEditor dialog, is there a way of accessing the changes to these options?
After crawling around, inspecting the ChartEditor object....
$.parseJSON(chartEditor.getChartSpecification())['options']
...returns what I'm looking for.
Just to add to Flippsie's answer, you can recreate the saved chart from the json returned from chartEditor.getChartSpecification()
var json = chartEditor.getChartSpecification(); // Or saved JSON value
var spec = JSON.parse(json);
// Get the chart details from the saved spec
var data = new google.visualization.DataTable(spec.dataTable);
var options = spec.options;
var chartType = spec.chartType || "BarChart";
// Instantiate and draw our chart, passing in some options.
window.chart = new google.visualization[chartType](document.getElementById('chart_div'));
chart.draw(data, options);
I have hooked up the content of ember-table with an ember-data model. I'm trying to get model object underlying the row that is currently selected. I've tried using this.get('selection') but to no avail. My ultimate goal is that i have an associated edit details view in a separate view that sits next to the table (aka list view) with a router (v2) that handles the transitioning between creating new models to insert into the table and edit the currently selected model (or eventually batch edit multiple models in the table). Here's the code sample:
App.TableView = Ember.Table.TablesContainer
.extend(Ember.Table.RowSelectionMixin).extend({
selectionBinding: 'controller.selection'
});
App.TableController = Ember.Table.TableController.extend({
...
selection: null,
selectionChanged: Ember.observer(function() {
this.transitionToRoute('selectedModel.edit', this.get('selection'));
}).observes('selection'),
...
I have solved this issue. What i hadn't realized is that selection is an enumerable (i'm guessing in preparation for multiple selection which would be awesome!) In the controller:
selection: null,
selectionChanged: Ember.observer(function() {
if(this.get('selection').length) {
selection0 = this.get('selection')[0];
this.transitionToRoute('selectedModel.edit', selection0);
}
}).observes('selection'),
I initially have the Google Visualization API Geomap on a world view (options['dataMode'] = 'regions') and I capture the 'regionClick' event when a country is clicked like so:
google.visualization.events.addListener(
geomap, 'regionClick', function (e) {
var rowindex = data.getFilteredRows([{column: 0, value: e['region']}]);
var location = data.getValue(rowindex[0], 3);
location.href = "?ISO=" + e['region'] + "&Location=" + location;
});
I then draw the map zoomed into the country in markers mode (options['dataMode'] = 'markers'). However, I can't seem to capture any events when the markers themselves are clicked.
The documentation ( http://code.google.com/apis/visualization/documentation/gallery/geomap.html#Events ) only refers to 'select' and 'regionClick' events neither of which are fired in this case. (Tested using Chrome 9, and IE 8.)
Has anybody had any success in doing this?
Many thanks.
According to http://groups.google.com/group/google-visualization-api/browse_thread/thread/2bcb89a1eb3c647d it's not currently supported.
I have it working on IE 8 and Chrome. First off, note the warning in the documentation if you are running this locally as file://
If that's not the case, make sure your google.visualization.GeoMap variable (the first argument to addListener) is indeed named geomap . If it is, add an alert() as the first line of code in the event handler and see if that fires. Lastly, note that unless the variable data is global, it will be out of scope if you try to access it from the event handler as you are doing.