21309 Posts in 5738 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1448 Views |
-
Drag and drop reordering of SS3 Grid Field

19 July 2012 at 3:13pm Last edited: 19 July 2012 3:14pm
I seem to be very good at creating ghost town posts on this forum but thought I'd have one last attempt.
There is very minimal documentation out there on SS3 Grid Fields at the moment. I am looking for a way to achieve drag and drop (or another method) reordering of the items in a Grid Field. Using the dataobjectmanager in SS2.4 I just had to add SortableDataObject::add_sortable_class('Classname') to my config file and hey presto, I could order the items.
Does anyone know how I can achieve this with Grid Fields in SS3?
-
Re: Drag and drop reordering of SS3 Grid Field

19 July 2012 at 3:46pm
Hey Fraser
There's a Sortable Grid Field module that provides a component for allowing drag and drop reordering of GridField objects. You just need to provide a sort field.
-
Re: Drag and drop reordering of SS3 Grid Field

4 January 2013 at 5:47am
Hi,
i have installed this plugin but i dont have an idea how i can use this module.
I try it on an example from the official tutorial (http://doc.silverstripe.com/framework/en/tutorials/5-dataobject-relationship-management) but it doesnt work.
Where i can find a usable tutorial?
-
Re: Drag and drop reordering of SS3 Grid Field

4 January 2013 at 5:58am Last edited: 4 January 2013 5:58am
Hi LuiLoop. Setting up the SortableGridField is pretty easy. Here's an example
In your DataObject class, you need to first create a column to sort by. I usually use something simple like SortID.
class MyDataObject extends DataObject {
public static $db=array(
'SortID'=>'Int'
);
}then where you're setting up your gridfield, add the SortableGridFieldComponent.
class Page extends SiteTree {
public static $has_many=array(
'MyDataObjects'=>'MyDataObject'
);public function getCMSFields(){
$fields=parent::getCMSFields();$fields->addFieldToTab('Root.Main',
GridField::create('MyDataObjects', 'Data Object',
$this->MyDataObjects(),
GridFieldConfig_RecordEditor::create()
->addComponent(new GridFieldSortableRows('SortID')) //use addComponent() function to add SortableGridFieldRows
)
);return $fields;
}
}hope that helps!
-
Re: Drag and drop reordering of SS3 Grid Field

4 January 2013 at 8:31pm Last edited: 4 January 2013 8:56pm
thx, now it works
But i have a litle second question. How i can create a DropDownField in my Gridfield - i cant find any documentation
-
Re: Drag and drop reordering of SS3 Grid Field

6 January 2013 at 9:39pm Last edited: 6 January 2013 9:40pm
Hi LuiLoop,
thanks for this post was very helpfull just now... with the dropdown list, i discovered i could use an Enum data type.
worked for what i needed, let me know if that works for you or if you find another way..static $db = array(
'Name' => 'Varchar(255)',
'Title' => 'Varchar(255)',
'Visible' => "Enum('Yes, No')",
'SortID'=>'Int',
);
| 1448 Views | ||
|
Page:
1
|
Go to Top |


