Show progress bar during report loading

Hi @PGriffith

I have report viewer… i am using to show report in table format … i have script in button but that is in template.
when i click the button its not showing any loading thing in the report viewer. so please help me out in this
how to show the loading symbol until i get the data

I have a script for 200 lines.where to use this progress bar and script to show loading in report viewer

because script is in separate template so please share your idea to fix this issue

I would need to see your actual code to offer any advice.

The script you set is in the template - is the progress bar also in your template? If your progress is not in the template then

def setProgressBarState(target=event.source.parent.getComponent('Progress Bar')):
	target.value = target.value + 10

will never be able to update it.

No progress bar i have to show in report viewer… Template is separate with button on it

SelectedReport = system.tag.read("[default]Common/Dynamic Report/Selected_Report").value
plantname = system.tag.read("[client]Plant_Name").value
Header_kWh = system.tag.read("[default]Common/Dynamic Report/Report_header_m2_MeterConsumption").value
Header_kWhTON = system.tag.read("[default]Common/Dynamic Report/Report_header_kWhTON_MeterConsumption").value
plant = plantname.replace(" Line", "")
params = {"plantname":plantname}
Database = system.db.runNamedQuery(project = "Metriks_Dev", path = "EMS/EM_DynamicReport_DB_Select", parameters = params)
Database = Database.getValueAt(0,0)
Unit =  event.source.parent.getComponent('Dropdown_Unit').selectedStringValue
if SelectedReport == "Meter Consumption Report" and plantname!= "Robertsbridge Line":
	first = event.source.parent.getComponent('Popup Calendar_StartDate').date
	second = event.source.parent.getComponent('Popup Calendar_EndDate').date
	
	start = event.source.parent.getComponent('Popup Calendar_StartDate').date
	event.source.parent.parent.StartDate = start
	end = event.source.parent.getComponent('Popup Calendar_EndDate').date
	event.source.parent.parent.EndDate = end
	endTime = second
	startTime = first
	ReportDS = system.tag.read('[default]Common/Dynamic Report/Report_header_name').value
	ReportDS = system.dataset.clearDataset(ReportDS)
	if Unit == 'kWh':
		TagUnit = 'Total_Consumption_kWh'
		path = "EMS/EM_DynamicReport_kwhm2_MeterConsumption"
		system.tag.write('[default]Common/Dynamic Report/Report_header_MeterConsumption',Header_kWh)
	if Unit == 'kWh/T':
		TagUnit = 'Total_Consumption_kWh_TON'
		path = "EMS/EM_DynamicReport_kwhTON_MeterConsumption"
		system.tag.write('[default]Common/Dynamic Report/Report_header_MeterConsumption',Header_kWhTON)
	
					
	Site_Electric = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/Total_Consumption/'+TagUnit+''
	params = {"database":Database, "tagpath": Site_Electric, "startDate":startTime,"endDate":endTime}
	print '...site electric.....'
	print params
	dataSet = system.db.runNamedQuery(project = "Metriks_Dev", path = path, parameters = params)
	delta = dataSet.getValueAt(0, 0)
	print delta
	newRow = ["Site_Electric","-","-","-",delta]
	ReportDS = system.dataset.addRow(ReportDS, newRow)
	Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'
	results = system.tag.browse(Path, {"tagType":"Folder","recursive":False}).results
	for result in results:
		if result.get("name"):
			Workshops = str(result['name'])
			Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'+Workshops+'/Total_Consumption/'+TagUnit+''
			params = {"database":Database, "tagpath": Path, "startDate":startTime,"endDate":endTime}
			dataSet = system.db.runNamedQuery(project = "Metriks_Dev", path = path, parameters = params)
			delta = dataSet.getValueAt(0, 0)
			newRow = [Workshops,"-","-","-",delta]
			ReportDS = system.dataset.addRow(ReportDS, newRow)
			Path = Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'+Workshops+'/'	
			Workshop = system.tag.browse(Path, {"tagType":"Folder","recursive":False}).results
			for result in Workshop:
				Areas = str(result['name'])
				Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'+Workshops+'/'+Areas+'/Total_Consumption/'+TagUnit+''
				params = {"database":Database, "tagpath": Path, "startDate":startTime,"endDate":endTime}
				dataSet = system.db.runNamedQuery(project = "Metriks_Dev", path = path, parameters = params)
				delta = dataSet.getValueAt(0, 0)
				newRow = ["-",Areas,"-","-",delta]
				ReportDS = system.dataset.addRow(ReportDS, newRow)
				Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'+Workshops+'/'+Areas+'/'	
				Area = system.tag.browse(Path, {"tagType":"Folder","recursive":False}).results
				for result in Area:
					ProcessSteps = str(result['name'])
					Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'+Workshops+'/'+Areas+'/'+ProcessSteps+'/Total_Consumption/'+TagUnit+''
					params = {"database":Database, "tagpath": Path, "startDate":startTime,"endDate":endTime}
					dataSet = system.db.runNamedQuery(project = "Metriks_Dev", path = path, parameters = params)
					delta = dataSet.getValueAt(0, 0)
					newRow = ["-","-",ProcessSteps,"-",delta]
					ReportDS = system.dataset.addRow(ReportDS, newRow)
					Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'+Workshops+'/'+Areas+'/'+ProcessSteps+'/'			
					PS = system.tag.browse(Path, {"tagType":"Folder","recursive":False}).results			
					for result in PS:
						Equipments = str(result['name'])
						Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'+Workshops+'/'+Areas+'/'+ProcessSteps+'/'+Equipments+'/Total_Consumption/'+TagUnit+''
						params = {"database":Database, "tagpath": Path, "startDate":startTime,"endDate":endTime}
						dataSet = system.db.runNamedQuery(project = "Metriks_Dev", path = path, parameters = params)
						delta = dataSet.getValueAt(0, 0)
						newRow = ["-","-","-",Equipments,delta]
						ReportDS = system.dataset.addRow(ReportDS, newRow)
					system.tag.write('[default]Common/Dynamic Report/Report_header_name',ReportDS)
					window = system.gui.getParentWindow(event)
					window.getComponentForPath("Root Container.Report Viewer").reportPath = '' 
					window.getComponentForPath("Root Container.Report Viewer").reportPath = 'Meter Consumption Report'

this is the script i am using in template in button

Can you show a picture of the object heirarchy for this window, I’m not sure I follow.

Is it something like this

Window
    |    -  ReportViewer
    |    -  ProgressBar
    |    -  TemplateButton

Also if you can show your hierarchy for inside the template itself.

If the above is the case though, where your template is another component on the same screen as the progress bar, and the script is inside the template, then my first statement is true - your template from inside the script cannot go outside of it to get and change the progress bar (as far sa I know, perhaps there’s some undocumentated way).

Is there a reason you can’t make your Button a first order object? Then your scripts on the button would be able to access the other components on the screen.

See my script that is in template when i click the button it will write to the report viewer in same screen.

my question is how to use progress bar or some time of loading in report viewer until the script executes fully.

That’s what I am saying you can’t do. You cannot, from inside a template script, reach outside to modify another GUI component by reference. Things inside the template only know about each other. You would need to think of another way to do this.

If you make a brand new button (not in a template) on the screen, and put this script in and try that - does it work as expected?

Edit: Sorry - I just saw you do try to do it by getting window. So it seems like maybe you should. But given now you’re inside a long running script (and this script is inside a invokeLater?), it might be tricky.

ok any kind of animated gif can we use… make it visible until the script fully executes?

window = system.gui.getParentWindow(event)
window.getComponentForPath("Root Container.Report Viewer").reportPath = '' 
window.getComponentForPath("Root Container.Report Viewer").reportPath = 'Meter Consumption Report'

Does this part of your script work as expected?

yes it works fine… getting all data… only think i am looking is loading symbol

Reports I believe have a reportLoading boolean property, so you can make an animation/component that has a visibility binding of {Root Container.Report.reportLoading} or whatever your path is.

ok i will check it out

You can do this by creating a custom property in your template, which you update in your button script.
Then on the window, where you place your template and ProgressBar, you bind the ProgressBar value property to the template custom property.
UpdateProgressBarFromTemplate
Import this in your project (it’s from the latest v8.1.12):
UpdateProgressBarFeomTemplate_2021-11-19_1912.zip (10.9 KB)

2 Likes

Thanks i will Check it out

@zxcslo

I have these lines in template button…
where to paste your template button progress bar script in my scripts? or i have to put in separately in action n performed?
can you please let me know

Which lines…?

SelectedReport = system.tag.read("[default]Common/Dynamic Report/Selected_Report").value
plantname = system.tag.read("[client]Plant_Name").value
Header_kWh = system.tag.read("[default]Common/Dynamic Report/Report_header_m2_MeterConsumption").value
Header_kWhTON = system.tag.read("[default]Common/Dynamic Report/Report_header_kWhTON_MeterConsumption").value
plant = plantname.replace(" Line", "")
params = {"plantname":plantname}
Database = system.db.runNamedQuery(project = "Metriks_Dev", path = "EMS/EM_DynamicReport_DB_Select", parameters = params)
Database = Database.getValueAt(0,0)
Unit =  event.source.parent.getComponent('Dropdown_Unit').selectedStringValue
if SelectedReport == "Meter Consumption Report" and plantname!= "Robertsbridge Line":
	first = event.source.parent.getComponent('Popup Calendar_StartDate').date
	second = event.source.parent.getComponent('Popup Calendar_EndDate').date
	
	start = event.source.parent.getComponent('Popup Calendar_StartDate').date
	event.source.parent.parent.StartDate = start
	end = event.source.parent.getComponent('Popup Calendar_EndDate').date
	event.source.parent.parent.EndDate = end
	endTime = second
	startTime = first
	ReportDS = system.tag.read('[default]Common/Dynamic Report/Report_header_name').value
	ReportDS = system.dataset.clearDataset(ReportDS)
	if Unit == 'kWh':
		TagUnit = 'Total_Consumption_kWh'
		path = "EMS/EM_DynamicReport_kwhm2_MeterConsumption"
		system.tag.write('[default]Common/Dynamic Report/Report_header_MeterConsumption',Header_kWh)
	if Unit == 'kWh/T':
		TagUnit = 'Total_Consumption_kWh_TON'
		path = "EMS/EM_DynamicReport_kwhTON_MeterConsumption"
		system.tag.write('[default]Common/Dynamic Report/Report_header_MeterConsumption',Header_kWhTON)
	
					
	Site_Electric = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/Total_Consumption/'+TagUnit+''
	params = {"database":Database, "tagpath": Site_Electric, "startDate":startTime,"endDate":endTime}
	print '...site electric.....'
	print params
	dataSet = system.db.runNamedQuery(project = "Metriks_Dev", path = path, parameters = params)
	delta = dataSet.getValueAt(0, 0)
	print delta
	newRow = ["Site_Electric","-","-","-",delta]
	ReportDS = system.dataset.addRow(ReportDS, newRow)
	Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'
	results = system.tag.browse(Path, {"tagType":"Folder","recursive":False}).results
	for result in results:
		if result.get("name"):
			Workshops = str(result['name'])
			Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'+Workshops+'/Total_Consumption/'+TagUnit+''
			params = {"database":Database, "tagpath": Path, "startDate":startTime,"endDate":endTime}
			dataSet = system.db.runNamedQuery(project = "Metriks_Dev", path = path, parameters = params)
			delta = dataSet.getValueAt(0, 0)
			newRow = [Workshops,"-","-","-",delta]
			ReportDS = system.dataset.addRow(ReportDS, newRow)
			Path = Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'+Workshops+'/'	
			Workshop = system.tag.browse(Path, {"tagType":"Folder","recursive":False}).results
			for result in Workshop:
				Areas = str(result['name'])
				Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'+Workshops+'/'+Areas+'/Total_Consumption/'+TagUnit+''
				params = {"database":Database, "tagpath": Path, "startDate":startTime,"endDate":endTime}
				dataSet = system.db.runNamedQuery(project = "Metriks_Dev", path = path, parameters = params)
				delta = dataSet.getValueAt(0, 0)
				newRow = ["-",Areas,"-","-",delta]
				ReportDS = system.dataset.addRow(ReportDS, newRow)
				Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'+Workshops+'/'+Areas+'/'	
				Area = system.tag.browse(Path, {"tagType":"Folder","recursive":False}).results
				for result in Area:
					ProcessSteps = str(result['name'])
					Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'+Workshops+'/'+Areas+'/'+ProcessSteps+'/Total_Consumption/'+TagUnit+''
					params = {"database":Database, "tagpath": Path, "startDate":startTime,"endDate":endTime}
					dataSet = system.db.runNamedQuery(project = "Metriks_Dev", path = path, parameters = params)
					delta = dataSet.getValueAt(0, 0)
					newRow = ["-","-",ProcessSteps,"-",delta]
					ReportDS = system.dataset.addRow(ReportDS, newRow)
					Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'+Workshops+'/'+Areas+'/'+ProcessSteps+'/'			
					PS = system.tag.browse(Path, {"tagType":"Folder","recursive":False}).results			
					for result in PS:
						Equipments = str(result['name'])
						Path = '[MQTT Engine]Edge Nodes/'+plant+'/Energy/Reports/Static Reports/Electric/'+Workshops+'/'+Areas+'/'+ProcessSteps+'/'+Equipments+'/Total_Consumption/'+TagUnit+''
						params = {"database":Database, "tagpath": Path, "startDate":startTime,"endDate":endTime}
						dataSet = system.db.runNamedQuery(project = "Metriks_Dev", path = path, parameters = params)
						delta = dataSet.getValueAt(0, 0)
						newRow = ["-","-","-",Equipments,delta]
						ReportDS = system.dataset.addRow(ReportDS, newRow)
					system.tag.write('[default]Common/Dynamic Report/Report_header_name',ReportDS)
					window = system.gui.getParentWindow(event)
					window.getComponentForPath("Root Container.Report Viewer").reportPath = '' 
					window.getComponentForPath("Root Container.Report Viewer").reportPath = 'Meter Consumption Report'

this is the script i am having in template button… after this script finish i want to show in 100 percent in progress bar

Have you looked at the sample project I uploaded?

Yes i checked its return in action performed i tired same script in action performed but its not showing loading… Once the script which i return in mouse clicked executed … Its just showing 100 percent in progres bar

Thats why i confused where to use this script