29/04/2010 11:09am

PHP | Problem - Filter not applied when using pagination on TableListField


function getResultFields($controller, $ParentClass = NULL, $ParentID = NULL){

$Filter = '';
if($ParentClass && $ParentID){
$Filter = $ParentClass.'ID='.$ParentID;
}

$resultSet = new DataObjectSet();
$filter = $Filter;
$sort = $this->class.".Name ASC";
$join = '';
$instance = singleton($this->class);
$query = $instance->buildSQL($filter, $sort, null, $join);
$query->groupby[] = $this->class.'.ID';


$tablefield = new TableListField(
$this->class,
$this->class,
array_merge($this->stat('summary_fields'), array('EditLink' => ''))
);
$export = '';
if(DataObject::get_one($this->class, $Filter)){
$export = 'export';
}
$tablefield->setPermissions(array(
$export,
'delete'
));
// custom SQL for CSV
$tablefield->setFieldListCsv($this->stat('summary_fields'));
$tablefield->disableSorting();
$tablefield->setCustomQuery($query);
$tablefield->setShowPagination(true);
return $tablefield;
}


Post Comment