Powertable set data property from CellEdited

I'm trying to run this on a CellEdited but it does not set the value of self.data to the query below. the query is correct i test it outside. but self.data does not change, can anyone tell me why?

def onCellEdited(self, rowIndex, colIndex, colName, oldValue, newValue):
		
	orderid =  self.parent.OrderID
	invoiceid = self.parent.ID
	ordertype = self.parent.ordertype
	locationfrom = self.parent.locationfrom

	if colName == 'id' and newValue != oldValue:
		if newValue == 0:
			print "entro a borrar"   
	     	system.db.runNamedQuery("Orders/DeleteInvoiceTempPallet", {"PALLET_ID": old Value, "ORDER_ID": invoiceid, "ORDER_TYPE": ordertype})
		    self.data = system.db.runNamedQuery("Orders/SelectCustomInvoiceTempPallet", {"ORDER_ID": invoiceid, "LOCATION_FROM": locationfrom})

Your indentation is wrong. Everything under def should be indented one tab stop.

Thanks for pointing that out, it but it was when I pasted the code here that I made the mistake, in Igntion my code it was correct , now I have corrected here also. the print runs, and the first name query also runs, but i can't set the data property with the self.data

How is the data initially set? Do you have a data binding? If so, consider replacing the last line of your script with system.db.refresh(self, data)

no binding, i want to set data from that script

I have a powertable in vision with no binding,
I need to edit the X column and want to save the edited column even after client is relaunched,
now its keeping the values until i close the vision client, after i relaunch its showing me old values ( from designer probably).

I have the following script on cell edited -

def onCellEdited(self, rowIndex, colIndex, colName, oldValue, newValue):
	self.data = system.dataset.setValue(self.data, rowIndex, colIndex, newValue)

Then you need to save the content somewhere. Typically, that would be a database, and you would typically use a binding to load that content back in on startup.

There's no magic wand.

1 Like