Adrian Klaver wrote:
> On Monday 14 January 2008 11:48 am, johnf wrote:
>> On Monday 14 January 2008 11:34:35 am Adrian Klaver wrote:
>>> -------------- Original message ----------------------
>>> From: johnf <[EMAIL PROTECTED]>
>>>
>>>> On Monday 14 January 2008 11:05:55 am Ed Leafe wrote:
>>>>> On Jan 14, 2008, at 12:48 PM, johnf wrote:
>>>>>> Open a form with a bizobj that contains the field 'mytest' as in
>>>>>> above;
>>>>>> open dShell
>>>>>> self.new()
>>>>>> mybiz=self.getBizobj()
>>>>>> mybiz.getFieldVal('mytest')
>>>>>> u''
>>>>>>
>>>>>> I get a blank field. In fact I have not been able to reproduce
>>>>>> anything like
>>>>>> what you are getting.
>>>>> Calling new() does no interaction with the database. There is no way
>>>>> to get the values from the database without writing your own code to
>>>>> do so.
>>>>>
>>>>> -- Ed Leafe
>>>>> -- http://leafe.com
>>>>> -- http://dabodev.com
>>>> That's what I said the first time. However, Adrian states the
> following:
>>>>> Dabo is aware of the default values. When I call self.new() the
>>>>> Dropdown
>>>> Lists
>>>>
>>>>> are populated with the correct default values from Postgres. Those are
>>>>> the self.'RegID'.Value items above.
>>>> I can't figure out where the values are coming from if they are not in
>>>> Dabo somewhere?
>>> These are Dropdown Lists so the values are in the Choices property of the
>>> control. The thing is that the values that show up as the Value of each
>>> control when I call new() is the correct default value. To get that Value
>>> into the control the correct value is selected from the Choices list. The
>>> default value is not the first item in the list either by position or
>>> alphabetically, so it is not a case of displaying the first value. I will
>>> have to more digging to figure this out. I have to run right now so it
>>> will have to wait until tonight.
>>>
>>>
>>>
>>> --
>>> Adrian Klaver
>>> [EMAIL PROTECTED]
>> in the Form code afterInit() add the following:
>> self."RegID".Position=0
>> where "RegID" is the ID of the dropdown list. Check to see if that works
>> for you - on the insert.
> Actually this should be self."RegID".PositionValue=0. Position returns or
> sets
> the position of the control on the form whereas PositionValue selects the
> index value of the Choices. This works only if the PositionValue being set
> is different from the value that is already there. As the values that appear
> when a new record is created are the correct default values I want to keep
> them. I have run through everything several times and my original analysis
> holds, the values in the Dropdown Lists are not being picked up for inclusion
> in the INSERT statement.
> Before I go any further I want to make I understand SaveNewUnchanged. If it
> is
> set to False (the Default setting) , when one saves a new record only the
> field values in the ui that were entered by hand or changed are saved. If it
> is set to True all values in a new record are saved. Even though I have
> SaveNewUnchanged = True it is acting like =False. In other words though the
> values for each Dropdown List is set it not being picked up the process the
> builds the INSERT query. At this point I know this is what is happening or
> not happening as the case may be. I would suggest creating a test form with
> Dropdown lists and try it for yourself.
> Furthermore I am not sure I believe that there is no interaction between the
> control and the database in regards to default values, at least for Dropdown
> Lists. If I do not have the database default value as one of the Choices or
> Keys then I get the error- 'ValueError: String must be present in the
> choices.' when I create a new record. This is before I do anything with the
> record. The behavior of the DropDown List when you create a new record is the
> same as when you navigate through existing records, the displayed value and
> the control property Value are both equal to the database value. In the case
> of a new record this is the database default value for the column, unless the
> Choice or Key lists don't have the value in which case the value is
> PositionValue=0. This is the same behavior observed when navigating existing
> records. By the way I regard this as a bug as it leads the user to thinking
> they are looking at the actual value for the field when in fact they are not.
> The error output to the terminal shows the ValueError mentioned above ,
> however it is not propagated to the ui. Again set up a test form and see
> what happens, I know what I am seeing.
> As to the constraint issues, they are after the fact issues. They occur
> because the INSERT statement is not supplying the necessary values to the
> database. Yes, I can and have (see my previous posts) run the new() procedure
> without constraints. It was successful in that the INSERT succeeded but
> failed in that it did not INSERT all the values from the form record to the
> database record.
>> Later you can use validation to better control the input from the user.
>
You have to set a DefaultValue in your bizobj for the underlying
database field of your DropDown List.
e.g.:
self.DefaultValues['db_field_for_dropdownlist'] = 12345
I you then call new() for a new record the dropdown list
shows the value which was set with your DefaultValue.
I tested it in one of my forms and it works even if the
DropDownList isn't touched by the user.
Uwe
_______________________________________________
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/dabo-users/[EMAIL PROTECTED]