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.

General Questions

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

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

Basic Gridfield + Sortable + Pagination Example SilverStripe3 ss3


4 Posts   1044 Views


10 August 2012 at 9:01pm (Last edited: 10 August 2012 9:02pm), Community Member, 107 Posts

Hi, I see many question about using the GrildField & sortable module , so here is an example of how to get the working (tesed on SS3.0.1):
download the files & see the example , I provided a basic template file too so you can give it a quick drive test ;)

Note that you will need to download the Sortable Module from :

Attached Files

31 August 2012 at 2:15am Community Member, 107 Posts

Hi: for auto sorting of object when adding new items, you need to add this code to your Object , for example:
if Gallery has_many GalleryImages , add this code on the GalleryImages class :

function onBeforeWrite() {
if (!$this->SortID) {
$this->SortID = $this->getNextSortID();

function getNextSortID() {
$getDataList = $this->SGallery()->Images();
if (!$getDataList || $getDataList->Count() == 0) {
return NULL;
} else {
return $getDataList->first()->SortID + 1;
PM me on the IRC if you have any questions


31 August 2012 at 2:36am Community Member, 27 Posts

Shouldn't have to manually auto increment the number SortableGridField detects this the next time the GridField is displayed. It will not update if you're still in the Edit/Add Form.


5 September 2012 at 12:35am Community Member, 107 Posts

yep, its fixed now.. I guess I had an old copy of the module . as of 4/9/12 the module will take care of incrementing :D