Thanks. To complicate things further I have to be able add new columns dynamically which are the same kind of "relational" columns.
For now I managed to solve it with a hack. I abandoned setting the actual relation object into the renderer, and instead just use the same object everywhere on the same row. I set a fake dataField property to a property which exists in the "X object", and then just not use it for rendering but set the text I want in the custom renderer. Afaik. all sorting etc. works correctly now and no exceptions are being thrown. --- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote: > > You could pre-process the different objects into a collection of display > objects. > > Tracy > > > > ________________________________ > > From: [email protected] [mailto:[EMAIL PROTECTED] On > Behalf Of kallebertell > Sent: Friday, March 28, 2008 8:03 AM > To: [email protected] > Subject: [flexcoders] Datagrid with different objects in each cell > > > > I have a case of a datagrid where I have to fetch a value from different > objects depending on the column. > > ---X----A---B---C---D- > 1--X1---A1--B1--C1--D1 > 2--X2---A2--B2--C2--D2 > 3--X3---A3--B3--C3--D3 > 4--X4---A4--B4--C4--D4 > > The datagrid's dataprovider is an ArrayCollection of objects of type X. > > What I'm trying to do is showing relations between objects of type X to > types A, B, C and D. > These relations are objects themselves and have their own properties. It > is this relational property I want to display. > > I've solved this by having special column which gets the object > (A,B,C,D) they're being relating to passed into them. > I then use a special renderer which overrides grabs the object it's > being related to (A,B,C or D) from its parent column; > and uses this info to pick out the correct (overriding set data) > relation object from the X object. > > This all works fine, until I try to sort one of the special columns; and > I do need to be able to sort them. > I almost got it working by doing a custom sortCompareFunction in the > column, but then it fails on an exception, "Error: Find criteria must > contain at least one sort field value.", although it seemed to get the > sorting done. > > Diving into the source it looks like it is a strong assumption (at least > in sorting) that each row in the datagrid is representing a property > from the same object, > which of course it isn't for me. > > I thought I'd put a message here before continuing hacking away at this. > > Anyone done something similar to this and is it possible to do this > elegantly? >

