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.

Data Model Questions /

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

Ordering linked objects in a GridField


Go to End


3 Posts   1098 Views

Avatar
Voodoo Priest

Community Member, 32 Posts

28 September 2015 at 11:53pm

Hi,
I've recently upgraded a website from 2.4.13 to 3.0.x and I have a question.

I'm using a Gridfield control to associate objets in a many to many relation. For instance, suppose we are associating products and categories. Each product can be associated with several categories and categories can contain several products. In the CMS, a Gridfield control (with a GridFieldConfig_RelationEditor config) is present when editing a Category object.

Is it possible to order Products so that a specific product is shown first? I have P1, P2 and P3 in Category1, is it possible to somehow reorder the list so as to have say P3, P1, P2? Is there an easier way than breaking all links and reestablishing them in the desired order?

Thank you.

Avatar
helenclarko

Community Member, 166 Posts

29 September 2015 at 9:06am

Hi Voodoo Priest,

Have you taken a look at the sortable Gridfield module?

https://github.com/UndefinedOffset/SortableGridField

It takes a little bit of configuring, but should do the trick for reordering your gridfields.

-helenclarko

Avatar
Voodoo Priest

Community Member, 32 Posts

29 September 2015 at 6:59pm

Thanks for the pointer. I have downloaded the module and will report here on how implementing it went. Thx.