15 May 2009 at 11:54pm
I have this page where I'm using the DataObjectManager to manage a dataobject that in its turn has a has_one relation to another dataobject. I've created a dropdown within the getCMSFields_forPopup() function and that works very well, no probs here.
Now I'd like to show the content of one of the fields (let's say the Name) of the selected relation in the DataObjectManagers list. The selection query that collects the fields for the listing doesn't acknowledge that the managed object has this has_one relation, so no join is executed.
Can anybody think of a way around this - or am I missing something obvious here?
22 March 2010 at 11:01am
Never thought of using a custom getter. It does indeed work in order to create and populate this extra column - except that when you do a column sort, it breaks. The SQL query executed is trying to sort using a field that doesn't exist.
Same goes with your second suggestion of using 'Table.Field', as the SELECT clause doesn't include the field automatically. I stuck a LEFT JOIN in the $sourceJoin param and somehow that fixed it. Can't say I fully understand how!
What this seems to have done is disable sorting of that field. Any idea how to get sorting working?
22 March 2010 at 1:19pm
Ahh, I see! That at least prevents sorting of fields using a getter. I haven't switched to the latest rev yet. Got to check a bug and get back to you on it first!
I've gone for the join clause option - and probably will do from now on as, even though you can't sort the column, you can create working filters that refer to the joined field. For those interested, I did so using
'Filter by Sector',
A word of warning - there isn't a lot of flexibility when dealing with fields of the same name in this case. I had to change Category.Name to Category.CategoryName to prevent Sector.Name appearing in both columns.