On Wednesday 13 April 2005 15:12, Frank Sch�nheit - Sun Microsystems, Inc. 
wrote:
> Hi Severin,
>
> Before answering the original question, let me ask the following:
>
> Sure your data structure, ehm, does make sense? :)

Hi Frank,

I should have known better that somebody _would_ ask :) Yes, I'm quite 
confident, but admittedly not exactly in what I described, but in what I 
actually set up. What I didn't mention, amongst other things, is that the 
"function" table has one more column "person_id", so the form I'm talking 
about is actually a subform. Every person holds a variable number of 
"function"s. Furthermore, "organization" also has a column "type_id", and 
there is a another table to hold valid combinations of "function_type"s and 
"organization_type"s, which I finally use to get a list of all organizations 
(a view named "organization_as_string") that match the given "function_type" 
in the first column.

I'm really sorry if I wasted your time, trying to make sense of the structure 
I described, but I thought it didn't change the actual problem I have, so I 
left it out, with the intention to not complicate things. Well, bad idea. 
Again, I'm sorry.

> > [dynamic listbox content]
> > I need something like "SELECT name, id FROM organization WHERE
> > function_type_id =
> > <value_of_the_first_column_which_is_the_function_type_id>"
>
> Changing the content of a listbox, which is filled from a select
> statement, is, well, non-trivial, but perhaps possible - with scripting.
>
> As a rough idea, you need to listen for changes in the selection of the
> first list box, create a new SQL statement respecting the new value, and
> set it as list source at the second list box. This should automatically
> rebuild the list.
>
> Reacting on the change in the list selection is the difficult part,
> since as long as you don't leave the control, the value is not yet
> propagated to the form, but only part of the control (read the
> Developer's Guide about forms to understand the difference, and to see
> when control values are committed to where :).
>
> You should be able to get the grid control (*not* the grid control
> model), obtain it's "column control" (*not* the column model), and
> listen for the proper event, which is fired every time the selection
> changes.
>
> Not sure at the moment whether this can be done programmatically only.
> It might be (I didn't try) that "Item status changed", in the properties
> of the list box column is the event you need to add a macro to.
>
>
> If you can confirm that your data structure is what you need :), and
> tell us what you already did, what worked, and what didn't, we could go
> into detail :)

So I can confirm :)

Since, as I described, none of the listbox's events seem to get triggered, 
I've installed an event handler in some randomly chosen other field's 
properties.

If I now select a function_type in the first column, then trigger the event by 
focusing and unfocusing "the other field", the event handlers gets called and 
sets the correct query string for the second column's listbox, but nothing 
happens afterwards. The listbox's content is still the same. This is probably 
due to the control/control model thingy you mentioned :)

I then added a call to the reload() function of the tablecontrol after setting 
the new query string, but that is, of course, also wrong, because it then 
uses the same query string for each row as it loads, but these generally have 
different "function_type"s...

Here's some code:

--->
oDoc = ThisComponent
oFF  = oDoc.DrawPage.Forms.getByName( "Standard" ).getByName( "Functions" )
oTC  = oFc.getByName( "TableControl" )

' Index 0: id
' Index 1: person_id
' Index 2: function_type
' Index 3: organization

oFunctionColumnModel = oTC.getByIndex(2)
oOrgColumnModel = oTC.getByIndex(3)

' Reformated for email purposes
oOrgColumnModel.ListSource = Array("SELECT text, organization_id" _
                                 + "FROM organization_as_string" _
                                 + "WHERE function_type_id = " & _
                                 + oFunctionColumnModel.BoundField.Value )

' Here was the experimental call to reload()
' oFF.reload
<---

So to me, it currently seems to boil down to two problems:
1. Listbox events not being triggered
2. Listbox contents not being updated after updating its query string,
   probably due to my yet deficient grasp of models and controls...

Thanks very much for your help and kind regards,

Severin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to