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

Grid-Field Buttons?


Go to End


2 Posts   767 Views

Avatar
Micro

Community Member, 1 Post

26 February 2014 at 4:17pm

Edited: 26/02/2014 6:13pm

I am following the example here about gird-fields. My question is why is there a button on create on each of the columns? How would I get rid of it and have sortable columns instead?

http://doc.silverstripe.org/framework/en/reference/grid-field

This is the code from the example page. When displayed each column has a button above it that links to a non-existent page. How do I get rid of the buttons?

public function AllPages() {
    $gridField = new GridField('pages', 'All pages', SiteTree::get()); 
    $dataColumns = $gridField->getConfig()->getComponentByType('GridFieldDataColumns');
    $dataColumns->setDisplayFields(array(
        'Title' => 'Title',
        'URLSegment'=> 'URL',
        'LastEdited' => 'Changed'
    ));
    return new Form($this, "AllPages", new FieldList($gridField), new FieldList());
}

Attached Files
Avatar
Willr

Forum Moderator, 5523 Posts

1 March 2014 at 11:28am

You can manipulate the GridField through the GridFieldConfig system. http://doc.silverstripe.org/framework/en/reference/grid-field#configuration has an overview of how it works. To add sortable, you'll need a module like https://github.com/ajshort/silverstripe-gridfieldextensions which adds sortable rows.