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.

All other Modules /

Discuss all other Modules here.

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

SS 3.1 printColumns in modelAdmin


Go to End


3 Posts   1009 Views

Avatar
timo

Community Member, 47 Posts

16 August 2014 at 10:06pm

How can i set printColumns in modelAdmin?
not export CSV but Print.

private static $printColumns = array(
'Title' => 'Titel',
'SubTitle' => 'SubTitel',
'Display' => 'Display',
'EventContent' => 'SeminarText',
'EnrolmentText' => 'Text bei Anmeldung'
);

Thanks.timo.

Avatar
Kirk

Community Member, 67 Posts

18 August 2014 at 9:14am

I would suggest looking into setting $summary_fields on the ModelAdmin.
This will only display the columns you specify in the ModelAdmin and then you can use the default print button.

For more details see the Summary Fields section at http://doc.silverstripe.org/framework/en/reference/dataobject[\url]

Avatar
timo

Community Member, 47 Posts

18 August 2014 at 6:50pm

as far i noticed summary_fields will display fields in grid view.
in grid view i only want to show the title- field and the display- field.
the question is about the print button and the print- view with additional fields.
meanwhile with a lot of trials and errors this is working:

$gridField->getConfig()->removeComponentsByType('GridFieldPrintButton');
			$gridField->getConfig()->addComponent(new GridFieldPrintButton('before', array(
				'Title' => 'Titel',
				'SubTitle' => 'SubTitel',
				'Display' => 'Display',
				'EventContent' => 'SeminarText',
				'EnrolmentText' => 'Text bei Anmeldung'
			)));

so i had to remove the standard- button first.
but i couldn't get this to work :


$gridField->getConfig()->GridFieldPrintButton->setPrintColumns(array(
					'Title' => 'Titel',
					'SubTitle' => 'SubTitel',
					'Display' => 'Display',
					'EventContent' => 'SeminarText',
					'EnrolmentText' => 'Text bei Anmeldung'
				));

anyway here comes the next question:

instead of the booleans value 0/1 i want to show icons:


class Event extends DataObject {

.....
public static $summary_fields = array( 
	   'Title' => 'Titel',
	   'CheckDisplay' => 'Display'     
	);

function CheckDisplay(){
		return $this->Display == '1' ? DBField::create_field('HTMLVarchar', '<img src="'.basename(dirname(dirname(__FILE__))).'/img/yes-content.png"/>') : DBField::create_field('HTMLVarchar', '<img src="'.basename(dirname(dirname(__FILE__))).'/img/no-content.png"/>');
		
	}

this is working and its displaying the icons in grid-view correctly in the page- view as also in model admin.
but when it comes to print out of modeladmin the path for the icons is not correct.

thanks.timo