We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Group grid rows by their content

How Do I?

Studio AF's avatar
Studio AF
12 posts
9 years ago
Studio AF's avatar Studio AF

I created a Grid field with two columns. First column is a Dropdown field which let my choose a service area (ex. “Bathroom”). Last column is a Textinput field used to create specific service (ex. “Shower”).

In this way I could have a structure like this:

1. Bathroom - Shower
2. Bathroom - Bidet
3. Living room - Sofa
4. Living room - TV
5. Bedroom - Bed
6. Bedroom - Closet
...

How can I output all Grid rows grouping all services by their area? Like this:

Bathroom
1. Shower
2. Bidet

Living room
1. Sofa
2. TV

Bedroom
1. Bed
2. Closet

What I’m trying to do is a list of hotel services like showed in attached image. Many thanks!

       
Pedro Guimaraes's avatar
Pedro Guimaraes
170 posts
9 years ago
Pedro Guimaraes's avatar Pedro Guimaraes

I’d change the Textinput field to a Textarea, then your grid row for Bathroom would have

Shower Bidet Sink

If you use Markdown as the text formatting for the Textarea and enter:

  1. Shower
  2. Bidet
  3. Sink

It’ll render as

<ol>
<li>Shower</li>
<li>Bidet</li>
<li>Sink</li>
</ol>
       
Studio AF's avatar
Studio AF
12 posts
9 years ago
Studio AF's avatar Studio AF

It could be an interesting solution! Thanks

       
Pedro Guimaraes's avatar
Pedro Guimaraes
170 posts
9 years ago
Pedro Guimaraes's avatar Pedro Guimaraes

If you want to use several rows for the same column (Bathroom), you could do a search:

ExpressionEngine Grid Documentation

       
Studio AF's avatar
Studio AF
12 posts
9 years ago
Studio AF's avatar Studio AF

But doing in that way I have to write a call for every “column group”. Right?

       
Pedro Guimaraes's avatar
Pedro Guimaraes
170 posts
9 years ago
Pedro Guimaraes's avatar Pedro Guimaraes

Indeed. Personally I’d go with the first solution unless there’s additional functionality you want. Another option could be categories / child categories…

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.