Forum Discussion

turtleData123's avatar
turtleData123
Cloud Apps
05-06-2024
Solved

Widget Display Not Updating On Dashboard Filter Change

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

 

3 Replies

    • turtleData123's avatar
      turtleData123
      Cloud Apps

      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. 

  • 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.