On Tuesday 23 February 2010 06:46:30 pm John wrote:
> Hi,
> Working with an interesting issue. I have a table (this is not my table)
> that contains a legal null value for a field ("product_category") and does
> not have a key (just text ). When I display the table in a grid all is
> fine with the null value because the grid displays '<None>' as I would have
> expected.
>
> I also have a dropdown for the same field that needs to allow a null
> or '<None>' for the choices (ValueMode = string because there is no key).
> I manually add the string '<None>' to the Choices. However, when I select
> the records on the grid that contain null values, the dropdown does not
> move to the related '<None>'. Selecting a record that does not contain a
> Null (IOW's a string for the value) the dropdown selection follows
> correctly. I can't add a null value to a Choices items. So I'm looking
> for suggestions.
>
> I was thinking I should bind a method to update the dropdown to the grid
> row selection. What are your thoughts.
>
> Johnf
Thanks everyone for the code. The following was used and appears to work.
Create a property:
def _getProdCat(self):
try:
val=self.itemBizobj.getFieldVal("product_category")
if val is None:
val = '<None>'
except:
val = '<None>'
return(val)
def _setProdCat(self, val):
if val == '<None>':
val = None
try:
self.itemBizobj.setFieldVal('product_category', val)
except:
pass
ProdCat = property(_getProdCat, _setProdCat)
Then use the following for the dropdown :
DataSource = self.Form, DataField = "ProdCat"
It's working. Thanks to Larry.
Johnf
_______________________________________________
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]