Refreshing Power table-Vision

Any ideas on this?? Still it is not yet solved

I want to make sure I understand this problem correctly. The load button script above works, but it is the save button script that is failing? Can I see a picture of the popup, the root container, and the datatable to help me understand how these components are related to each other? The problem could be in the way the datatable is being called.

No. Once I click the save button . Data is saving in db and popup screen closes but the table is not refreshed until i hit load button again

So the save works, but a subsequent press of the load button is required to refresh the table?
What you are wanting is the save button script to also refresh the table?

yep



iStart=event.source.parent.iStart
iEnd= event.source.parent.iEnd
iProcess=event.source.parent.iProcess
iMachineID= system.tag.readBlocking("[client]MachineNo")[0].value
vReason = event.source.parent.getComponent('Group').getComponent('Reason').text
iState=event.source.parent.iState
iLoss= event.source.parent.selectedLoss
iSubLoss= system.tag.readBlocking("[client]LossCategory")[0].value


if len(vReason)>20:
	system.gui.messageBox("Enter less than 20 char", "Warning")
else:
	params ={"iStart":iStart,"iEnd":iEnd,"iEqId":iMachineID, "iReason":vReason, "iLoss":iLoss,"iSubLoss":iSubLoss,"iState":iState}
	
	update = system.db.runNamedQuery("Production/Update_LossReason",params)

def refreshTable():
   window = system.gui.getWindow("Main Windows/Machine/Loss Time")
   dataTable = window.getRootContainer().getComponent("LossTime_Table")
   system.db.refresh(dataTable, "data")

#system.util.invokeLater(refreshTable)
system.nav.closeWindow("Main Windows/Machine/Update BreakDown Reason")

The table is in the root container, and the save button script is in the popup?

yep u are right

I see the problem, and I can't believe I missed it. The retrieved data is never assigned to the data table. Also, I have my concerns about the invokeLater; especially now that I've realized that the script sequence has nothing to do with the problem. My concern is that the definition will never be invoked if the window is closed, so I recommend removing it. Here is the corrected script:

def refreshTable(window):
	vProcessArea = window.getRootContainer().Process
	vStartDate = window.getRootContainer().getComponent('Group').getComponent('stDate').date
	vEndDate = window.getRootContainer().getComponent('Group').getComponent('endDate').date
	vEqId = window.getRootContainer().MachineNo
	vMinutes =  window.getRootContainer().getComponent('Group').getComponent('Dropdown').selectedValue
	params = {"iProcessArea":vProcessArea, "SDate":vStartDate, "EDate":vEndDate , "iEqId":vEqId,"iMinute":vMinutes}
	updatedData = system.db.runNamedQuery("MachineBoard/getLossTime", params)
	return updatedData
iStart=event.source.parent.iStart
iEnd= event.source.parent.iEnd
iProcess=event.source.parent.iProcess
iMachineID= system.tag.readBlocking("[client]MachineNo")[0].value
vReason = event.source.parent.getComponent('Group').getComponent('Reason').text
iState=event.source.parent.iState
iLoss= event.source.parent.selectedLoss
iSubLoss= system.tag.readBlocking("[client]LossCategory")[0].value
if len(vReason)>20:
	system.gui.messageBox("Enter less than 20 char", "Warning")
else:
	params ={"iStart":iStart,"iEnd":iEnd,"iEqId":iMachineID, "iReason":vReason, "iLoss":iLoss,"iSubLoss":iSubLoss,"iState":iState}
	update = system.db.runNamedQuery("Production/Update_LossReason",params)	
window = system.gui.getWindow("Main Windows/Machine/Loss Time")
updatedData = refreshTable(window)
dataTable = window.getRootContainer().getComponent("LossTime_Table")
dataTable.data = updatedData
system.db.refresh(dataTable, "data")
system.nav.closeWindow("Main Windows/Machine/Update BreakDown Reason")

Edit: corrected window source path in definition [I couldn't actually test this code, so I inadvertently overlooked that]

Hey Thanks.
I am getting the below error once save btn is clicked,.


Modified the code with correct path:

def refreshTable(window):
	vProcessArea = window.getRootContainer().parent.Process
	vStartDate = window.getRootContainer().getComponent('Date_Group').getComponent('StartDate_dropdown').date
	vEndDate = window.getRootContainer().getComponent('Date_Group').getComponent('EndDate_dropdown').date
	vEqId = window.getRootContainer().MachineNo
	vMinutes =  window.getRootContainer().getComponent('Date_Group').getComponent('Filter_dropdown').selectedValue
	params = {"iProcessArea":vProcessArea, "SDate":vStartDate, "EDate":vEndDate , "iEqId":vEqId,"iMinute":vMinutes}
	updatedData = system.db.runNamedQuery("MachineBoard/getLossTime", params)
	return updatedData
	
iStart=event.source.parent.iStart
iEnd= event.source.parent.iEnd
iProcess=event.source.parent.iProcess
iMachineID= system.tag.readBlocking("[client]MachineNo")[0].value
vReason = event.source.parent.getComponent('Group').getComponent('Reason').text
iState=event.source.parent.iState
iLoss= event.source.parent.selectedLoss
iSubLoss= system.tag.readBlocking("[client]LossCategory")[0].value


if len(vReason)>20:
	system.gui.messageBox("Enter less than 20 char", "Warning")
else:
	params ={"iStart":iStart,"iEnd":iEnd,"iEqId":iMachineID, "iReason":vReason, "iLoss":iLoss,"iSubLoss":iSubLoss,"iState":iState}
	update = system.db.runNamedQuery("Production/Update_LossReason",params)	
	
	
window = system.gui.getWindow("Main Windows/Machine/Loss Time")


updatedData = refreshTable(window)
dataTable = window.getRootContainer().getComponent("LossTime_Table")
dataTable.data = updatedData
system.db.refresh(dataTable, "data")
system.nav.closeWindow("Main Windows/Machine/Update BreakDown Reason")

Justin,

It is working fine.Only correction need to be done is

vProcessArea = window.getRootContainer().parent.Process
```to be corrected as,

vProcessArea = window.getRootContainer().Process

1 Like

Thanks; I'm glad to hear it's working. I corrected the error in my post.

1 Like