Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SS_Report problems


Go to End


792 Views

Avatar
quanto

Community Member, 91 Posts

12 March 2014 at 5:26am

I have two problems when i upgraded a site from 2.4 to 3.1:
problem 1: I'm trying to show xxx fields from parameterFields This doesn't work. The $params field remains empty
problem 2: I'm trying to export the report to csv, however after export I only get the ID's in my csv..

<?php

class CustomSideReport_TipcompetitieReport extends SS_Report{
  function title() {
    // the name of our report
    return "Tipcompetitie";
  } 
  
  function sourceRecords($params) {
    
    //$Pages = DataObject::get("TipcompetitieZend", null, "Kortebaan DESC", null, $limit);  
    $limit = isset($params['ResultsLimit']) ? $params['ResultsLimit'] : '';
    $Pages = TipcompetitieZend::get()->sort("Kortebaan DESC")->limit($limit);//, null, $limit);         
    return $Pages;
  } 
  
  function columns() 
  {
    $fields = array(
        'Naam' => array(
            'title' => 'Naam'
        ),
        'Woonplaats' => array(
            'title' => 'Woonplaats'
        ),
        'Kortebaan' => array(
            'title' => 'Kortebaan'
        ),
        'Emailadres' => array(
            'title' => 'Baan'
        ),
        'nr1' => array(
            'title' => 'Nummer 1'
        ),
        'nr2' => array(
            'title' => 'Nummer 2'
        ),
        'nr3' => array(
            'title' => 'Nummer 3'
        ),
        'nr4' => array(
            'title' => 'Nummer 4'
        ),
        
        'Created' => array(
            'title' => 'Invoerdatum',
            'casting' => 'SS_Datetime'
        )
        
    );
    return $fields;
  }

  public function parameterFields() 
  {
    $params = new FieldList();
     
    //Result Limit
    $ResultLimitOptions = array(
        50 => '50 Aanmeldingen',
        100 => '100 Aanmeldingen',
        200 => '200 Aanmeldingen',
        500 => '500 Aanmeldingen',
        Null => 'Alle aanmeldingen'
    );
     
    $params->push(new DropdownField(
        "ResultsLimit", 
        "Aantal aanmeldingen weergeven",
        $ResultLimitOptions/*,
        10*/
    ));
             
    return $params;
  }   
}
?>