cancel
Showing results for 
Search instead for 
Did you mean: 

Widget Display Not Updating On Dashboard Filter Change

turtleData123
9 - Travel Pro
9 - Travel Pro

Hi all,

So I am running the following script on my widget (using 'edit script') in order to grab the date of the maximum dollars for a year using a different bar chart widget on the dashboard, and display that date (along with the $ amount) on an indicator widget

 

var dateStr = '';

widget.on('processresult', function(e,v) {
	var results = widget.queryResult;
	console.log(results);
	

	
	var maxNum = results.value.data;
	var replaceNum = results.secondary.data;
	//var dateStr = '';
	console.log(results);
	var widg = dashboard.widgets.get('6633bbf55a7e230040304e8c');
	var widgResult = widg.rawQueryResult.values;
	console.log(widgResult);
	$.each(widgResult, function(index, item) {
		let date = item[0].data;
		let amt = item[1].data;
		if (amt === maxNum) {
			dateStr = date;
		};
	});
	//results.secondary.data = dateStr.substring(0, 10);
	//results.secondary.text = dateStr.substring(0,10);
});


widget.on('render', function(se, ev) {
	
	var results = widget.queryResult;
	results.secondary.data = dateStr.substring(0, 10);
	results.secondary.text = dateStr.substring(0,10);

});

widget.refresh();
		  

	

 

 This works, and gets me the proper date. However, when I open the dashboard (/refresh the page), or change filters, the displayed date doesn't update, and only updates when I do something like changing the widget's width on the dashboard manually, as though I am manually refreshing the widget's render state or something. 

Can anyone help me with a solution so that the widget properly displays the info without having to manually change its size to refresh the display?

 

Thanks in advance

 

1 ACCEPTED SOLUTION

HamzaJ
12 - Data Integration
12 - Data Integration

Hello @turtleData123 

I am not an expert on this, however I think it has to do with when this script is triggered (the widget event). If you change the event, the script will be triggered at a different moment. More on the events can be found here:

https://sisense.dev/guides/customJs/jsApiRef/widgetClass/

You could also try to use a dashboard-event

Hamza

View solution in original post

3 REPLIES 3

HamzaJ
12 - Data Integration
12 - Data Integration

Hello @turtleData123 

I am not an expert on this, however I think it has to do with when this script is triggered (the widget event). If you change the event, the script will be triggered at a different moment. More on the events can be found here:

https://sisense.dev/guides/customJs/jsApiRef/widgetClass/

You could also try to use a dashboard-event

Hamza

Thanks for the response,

Yeah I have been messing around changing the replacement lines and putting them into a 'ready' function but it doesn't seem to make a difference. Dashboard events might be the way to go, I'm looking into that now, thanks for the suggestion. 

DRay
Community Team Leader
Community Team Leader

Hi @turtleData123,

I wanted to follow up to see if the solution offered by @HamzaJ worked for you.

If so, please click the 'Accept as Solution' button so that other users with the same questions can find the answer faster. If not, please let us know so that we can continue to help.

Thank you.

David Raynor (DRay)