Ed Leafe wrote: > On Sep 5, 2009, at 3:18 PM, Ricardo Aráoz wrote: > > >>> Two questions here : >>> 1 - Is there a row change event for the grid? (looked it up in the >>> api >>> documentation but couldn't find it) >>> 2 - The table has two fields "Registro" and "Extension", let's say >>> Registro = 1234 and Extension = 2, I want the value "1234/2" to >>> show in >>> the first column of the grid. But if Registro = 1234 and Extension >>> = 0 >>> then I want "1234" to show. How can I code this? >>> >>> >> Ok, question #2 is done through a virtual field. What I still want to >> know is about the rowchange event. >> > > > dEvents.GridCellSelected should do what you need; you'll just have to > track if the change involves a different row: > > def onGridCellSelected(self, evt): > print evt.row, evt.col > > > -- Ed Leafe > Thanks Ed. It works.
But it generated yet another issue. I have : def onGridCellSelected(self, evt): if evt.row != self.PrevRow : self.PrevRow = evt.row self.Form.lblFechaOrigen.Caption = self.Form.PrimaryBizobj.Record.Fecha self.Form.lblRegistro.Caption = self.Form.PrimaryBizobj.Record.RegExt Where PrevRow is a custom property of the grid, with default value of -1 (type integer). My bizObj code is : -------------------------------------------------------------- #!/usr/bin/env python # -*- coding: utf-8 -*- import dabo class OpMejoraBizobj(dabo.biz.dBizobj): def afterInit(self): self.DataSource = "OpMejora" self.KeyField = "PKId" self.addFrom("OpMejora") self.addField("Registro") self.addField("Extension") self.addField("Fecha") self.addField("FKOrigen") self.addField("FKDestino") self.addField("Descripcion") self.VirtualFields['RegExt'] = self.formatRegExt self.VirtualFields['OrigenDesc'] = self.getSectorOrigen self.VirtualFields['DestinoDesc'] = self.getSectorDestino def formatRegExt(self): if self.Record.Extension > 0 : ret = '%s/%s' % (self.Record.Registro, self.Record.Extension) else : ret = '%s' % (self.Record.Registro, ) return ret def getSector(self): """Devuelve una tupla de dos listas con los sectores y sus claves primarias.""" crs = self.getTempCursor() crs.execute("select PKId, Nombre from Sector order by Nombre") ds = crs.getDataSet() nombres = [tupla['Nombre'] for tupla in ds] claves = [tupla['PKId'] for tupla in ds] return (claves, nombres) def getSectorOrigen(self): """Devuelve el nombre del sector origen""" crs = self.getTempCursor() crs.execute("select Nombre from Sector where PKId = ?" , (self.Record.FKOrigen, )) ds = crs.getDataSet() return ds[0]['Nombre'] def getSectorDestino(self): """Devuelve el nombre del sector destino""" crs = self.getTempCursor() crs.execute("select Nombre from Sector where PKId = ?" , (self.Record.FKDestino, )) ds = crs.getDataSet() return ds[0]['Nombre'] def validateRecord(self): """Returning anything other than an empty string from this method will prevent the data from being saved. """ ret = "" # Add your business rules here. return ret ---------------------------------------------------------------------------- Where getSector() is used to fill a dropList, and both OrigenDesc and DestinoDesc are used in stead of the corresponding foreign keys in a grid (is this the way to go?). and I'm getting the following error (if I comment both lines assigning label's caption a value it works ok. The captions are not changed even when I change rows in the grid, but the exception appears only once) : Traceback (most recent call last): File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dGrid.py", line 3565, in __onWxGridSelectCell self.raiseEvent(dEvents.GridCellSelected, evt) File "C:\Python25\lib\site-packages\dabo\dabo\ui\uiwx\dPemMixin.py", line 949, in raiseEvent super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args, **kwargs) File "C:\Python25\lib\site-packages\dabo\lib\eventMixin.py", line 93, in raise Event File "c:\docume~1\richie\config~1\temp\tmpbt9lai.py", line 1255, in onGridCell Selected self.Form.lblFechaOrigen.Caption = self.Form.PrimaryBizobj.Record.Fecha File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py", line 2536, in __getattr__ return self.cursor.getFieldVal(att) File "C:\Python25\lib\site-packages\dabo\dabo\db\dCursorMixin.py", line 815, i n getFieldVal raise dException.NoRecordsException(_("No records in the data set.")) dabo.dException.NoRecordsException: No records in the data set. --- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html --- _______________________________________________ Post Messages to: Dabo-users@leafe.com Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users Searchable Archives: http://leafe.com/archives/search/dabo-users This message: http://leafe.com/archives/byMID/4aa2e8ec.7080...@gmail.com