Skip navigation.
 
mlBinding varying NSPopUpButtonCells in NSTableView
FROM : Christiaan Hofman
DATE : Sun Oct 17 14:38:47 2004

Hi All,
I am having some problems to use bindings for to-many relationships in
NSTableViews with an NSPopUpButtonCell, where the to-many relationship
depends on the row.
I am trying something like this: I have a collection of objects, say of
class MainObject,
containing an NSMutableArray of objects (lets call the array property
'options'). It also has a 'selectedOption' property.

I want to bind the collection to an NSTableView, one row for each
MainObject. Furthermore, the options should be displayed in a
NSPopUpButtonCell, so that the user can choose a selectedOption for
each MainObject. I have set up some bindings for the tablecolumn
containing the popupbuttons as follows:

contents:
   arrangedObjects.options [mainArrayController]
contentValues:
   arrangedObjects.options.name [mainArrayController]
selectedObject:
   arrangedObjects.selectedOption [mainArrayController]

Here of course     mainArrayController has its contentArray bound to the
master array of MainObjects.

Note that this is similar to many examples for to-many bindings except
that the array of options is not the same for all objects, so I can not
bind another NSArrayController to my options and use its
arrangedObjects as the content of my popupbuttons.

At first sight this indeed works: the popupbuttons indeed display the
options. However the _number_ of the displayed options is cut off by
the length of the arrangedObjects (i.e. the number of MainObjects,
rather than the number of options). Example: if there are 2 MainObjects
(2 rows in the table) and say the first one has an options property of
length 5, then only the first 2 options are displayed in the
popupbuttoncell. As the values are taken properly from the options
property, this seems to me a bug of the bindings.

Does anyone know a workaround or have a better implementation of this?

Christiaan

Related mailsAuthorDate
No related mails found.