Jump to:

3445 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » How to using GroupedList?

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

Page: 1
Go to End
Author Topic: 352 Views
  • anudeepgi
    Avatar
    Community Member
    11 Posts

    How to using GroupedList? Link to this post

       function subraya(){
          return GroupedList::create(carspecification::get()->leftJoin("carspecificationscategory", "\"carspecificationscategory\".\"ID\" = \"carspecification\".\"CarSpecificationsCategoryID\"")->filter(array('CarsID' => $this->CarsID,'CarSpecificationsTypeID' => '4')));
       }

    <% loop $subraya.GroupedBy(CarSpecificationsCategoryID) %>
    <h3>$getCarSpeficCatName.Title</h3>
    <ul>
    <% loop $Children %>
    <li>$Title </li>
    <% end_loop %>
    </ul>
    <% end_loop %>

    What is the issue with this code everthing works properly but '$getCarSpeficCatName.Title' is not displaying anything

    Please help me..

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: How to using GroupedList? Link to this post

    Is getCarSpeficCatName defined on your car specification model?

    See the examples at http://doc.silverstripe.org/framework/en/howto/grouping-dataobjectsets

  • thomas.paulson
    Avatar
    Community Member
    75 Posts

    Re: How to using GroupedList? Link to this post

    public function getCarSpeficCatName () {
    return $this->Title;
    }

    add in car carspecificationscategory model class

  • anudeepgi
    Avatar
    Community Member
    11 Posts

    Re: How to using GroupedList? Link to this post

    What i want is Group based on Category ,

    CarSpecificationsPage.php

    function subraya(){
    return GroupedList::create(carspecification::get()->leftJoin("carspecificationscategory", "\"carspecificationscategory\".\"ID\" = \"carspecification\".\"CarSpecificationsCategoryID\"")->filter(array('CarsID' => $this->CarsID,'CarSpecificationsTypeID' => '4')));
    }
    I am querying join 2 table one 'carspecification' other one is 'carspecificationscategory' table

    carspecification table is have this feilds   
    ID
    ClassName
    Created
    LastEdited
    Title
    CarSpecificationsCategoryID
    CarSpecificationsTypeID
    Title Value
    CarsID
    TitleValue

    carspecificationscategory   
    ID
    ClassName
    Created
    LastEdited
    Title

    i need something like in view

    CategoryTitle1 - this from carspecificationscategory   
    Title1 - this from carspecification
    title2 - this from carspecification
    CategoryTitle2 - this from carspecificationscategory   
    Title1 - this from carspecification
    title2 - this from carspecification

    <% loop $subraya.GroupedBy(CarSpecificationsCategoryID) %>
    <h3>$carspecificationscategory.Title</h3>
    <ul>
    <% loop $Children %>
    <li>$Title </li>
    <% end_loop %>
    </ul>
    <% end_loop %>

    is ther any easy way to achieve this please explain

    352 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.