Hi mi32dogs,
yes I did find a solution, although its more like a little work around. Since the lazy loading thingy you just can't add fields via "setField". You have to execute the query in order to get to the underlying objects.
What I did was the following:
Query my DataObjects:
$Query = $DataObject::get()->where($sqlQuery)->sort($Sort);
$PaginationStart = $this->request->getVar('start') ?: 0;
$Records = new PaginatedList($Query, $this->request);
$Records->setPageLength(100); // $Records now hold my DataObjects
I then build my Dropbox Images in a simple array. My DataObject has a public property "DropboxImage".
$MyDataObjects= new ArrayList();
// Loop over $Record Query, this is where it actually gets executed...
foreach ($Records as $Record) {
if (isset($DropboxImages[$Record->LosID])) {
$Record->DropboxImage = count($DropboxImages[$Record->LosID]);
}
$MyDataObjects->push($Record);
}
Later on, I pushed in a array and let customize and renderWith do the rest.
$Data = array(
'Records' => $Records,
'MyDataObjects' => $MyDataObjects,
'DropboxImages' => $DropboxImages,
// ....
'PaginationStart' => $PaginationStart
);
return $this->customise($Data)->renderWith(array('MyPage_index', 'Page'));
Hope that helps!
:)