Web lists-archives.com

Combos & NULL values and/or 'no value selected'


I'm trying to find a sensible approach to dealing with NULL values,
combos, and database values. It's of course a valid situation where a
database field has a NULL value. It's also valid that someone wants to
SET a database field to NULL, by "somehow" de-selecting a currently
selected item in a combo.

How do I do this? :) There are a few approaches that come to mind ...

1) Is there an easy way for a user to *de-select* a selected item in a
combo? I don't see any way of doing this currently, but if there *was*
such a way, my problem would be solved. I'm having difficulty
connecting to signals like the button press event and populate-popup
event ( maybe combos don't have this ). Right-clicking the combo and
clicking an item 'de-select' might be ok, though not really obvious.

2) I've tried adding to the combo's model an initial row. All my combo
models have at least 2 columns - the ID and the text to be displayed.
So if I add an initial row with both the ID and text columns set to
NULL ( undef - I'm using perl - whatever ) ... I actually get the
desired effect ( both in setting and getting values between combo & DB
), but I also get warnings:

Use of uninitialized value in list assignment at
/usr/local/lib64/perl5/5.20.1/Gtk3.pm line 1572.
Argument "" isn't numeric in subroutine entry at
line 58.

 ... which is not really ideal. I don't think it's safe to use any
other values - 0, for example, might be a valid ID from the database.
Other than the issue of the STDOUT looking bad, is this a bad idea for
any other reason?

Maybe there are some other approaches that aren't occurring to me. Thoughts?

gtk-list mailing list