On Thursday 09 July 2009 02:09:19 pm Miguel Lopes wrote: > On Thu, Jul 9, 2009 at 2:06 AM, John<[email protected]> wrote: > > On Wednesday 08 July 2009 04:46:20 pm Miguel Lopes wrote: > >> I'm trying without success to have a grid with two checkboxes. > >> > >> The first checkbox (contactSelect) allows me to indicate which records > >> to select. the second indicates if the record is to be shared > >> (contactShare) (just something about the record). > >> My problem is that most checkbox clicks somehow affect the other > >> checkbox. This happens irrespectively of if I press contactSelect or > >> contactShare, and even affects records in different rows. > >> > >> I can't seem to find a solution for this. Here's my bizobj code. Any > >> ideas? > >> > >> class ContactBizobj(dabo.biz.dBizobj): > >> def afterInit(self): > >> > >> ..., ... > >> > >> self.VirtualFields.update({'contactSelect': > >> self.contactSelect, 'contactShare': self.contactShare}) > >> > >> def contactSelect(self): > >> if self.Record.contact_id in > >> self.__selectedContactsToAssign: # it's already selected, unselect > >> del > >> self.__selectedContactsToAssign[self.Record.contact_id] return False > >> else: > >> # not selected, select it - "False" means it is > >> not shared self.__selectedContactsToAssign[self.Record.contact_id] = > >> False return True > >> > >> def contactShare(self): > >> if self.Record.contact_id in > >> self.__selectedContactsToAssign and \ > >> self.__selectedContactsToAssign[self.Record.contact_id] == False: # not > >> shared, share it - "True" means it is shared > >> self.__selectedContactsToAssign[self.Record.contact_id] = True return > >> True > >> else: > >> return False > >> > >> ..., ... > >> > >> def initProperties(self): > >> self.__selectedContactsToAssign={} > >> > >> > >> TIA, > >> Miguel > > > > On the surface I don't see anything wrong with the bizobj. What does the > > grid code look like? In the grid you should be marking the fields as > > 'boolean'. I have just yesterday coded a grid with two check boxes and it > > appears to work OK. However, my fields are not virtual fields. > > I'm thinking on an alternative UI to accomplish the same goal, but > nevertheless I cannot spot what is wrong with this. > My grid code was initially in cdxml, but this coded version has the > same problem. > > class SetOpptyContactsAsDlg(dui.dForm): > > def initProperties(self): > self.CxnName = "mainCnx" > self.Height = 511 > self.Width = 976 > > def afterInit(self): > sz = self.Sizer = dui.dSizer('v') > > grid = dui.dGrid(self, RegID="dgSelectContact", > DataSource="contact", SelectionMode="Row") > grid.addColumn(Name="title", DataField="title_id", > DataType="integer", Width=64, Caption=u"Título", Expand=False) > grid.addColumn(Name="contact", DataField="contact", > DataType="string", Width=250, Caption=u"Contacto", Expand=False) > grid.addColumn(Name="contact_status_id", > DataField="contact_status_id", DataType="integer", Width=90, > Caption=u"Estado", Expand=False) > grid.addColumn(Name="account", DataField="account", > DataType="string", Width=250, Caption=u"Conta", Expand=False) > grid.addColumn(Name="contactSelect", > DataField="contactSelect", DataType="bool", Width=83, > HorizontalAlignment="Center", Caption=u"Selecciona", Expand=False) > grid.addColumn(Name="contactRole", DataField="contactRole", > DataType="integer", Width=125, HorizontalAlignment="Center", > Caption=u"Papel", Expand=False) > grid.addColumn(Name="contactShare", DataField="contactShare", > DataType="bool", Width=75, HorizontalAlignment="Center", > Caption=u"Cruza", Expand=False) > > hSz = dui.dSizer('h') > > hSz.appendSpacer(20, proportion=1) > self.btnCancel = dui.dButton(self, Caption=u"Cancela") > hSz.append(self.btnCancel, layout="x", proportion=0, border=5) > self.btnSave = dui.dButton(self, Caption=u"Guarda") > hSz.append(self.btnSave, layout="x", proportion=0, border=5) > > > sz.append(grid, layout="x", proportion=1, border=15) > sz.append(hSz, layout="x", proportion=0, halign="right", border=10) > > # Event bindings > self.bindEvent(dabo.dEvents.Close, self.onClose) > self.btnCancel.bindEvent(dabo.dEvents.Hit, self.onCancel) > self.btnSave.bindEvent(dabo.dEvents.Hit, self.onSave) > > def afterInitAll(self): > self.requery() > > def createBizobjs(self): > # Primary Bizobj - all the contacts in the db > contactBizobj = self.Application.biz.ContactBizobj(self.Connection) > self.addBizobj(contactBizobj) > > def onClose(self, evt): > self.Form.toggleEnabled() > > def onCancel(self, evt): > self.close() > > def onSave(self, evt): > # TODO: save > # create new oppty_contact records according to selections. > self.close() > > Miguel
I don't see anything that is stopping the check boxes from working correctly. However, I did notice that you are mixing cases with the field names. If you are using Postgres I know I have run into issues with mixed case. I can't recall what the problems were at the moment. Anyway I now keep all my fields lower case. _______________________________________________ Post Messages to: [email protected] 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/[email protected]
