Jump to:

3431 Posts in 1058 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Sort GridField by Column

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

Page: 1 2
Go to End
Author Topic: 2203 Views
  • pinkp
    Avatar
    Community Member
    168 Posts

    Re: Sort GridField by Column Link to this post

    Thanks again RuthAdele!

    So basically I have a list of Members. Each has a name, image, website, description and most importantly a Discipline.
    The discipline is chosen from an enum array, so this is limited to say 10 disciplines. There is potential to have 100's of Members so I think a form sounds best.

    Ideally I would have the user visit the Members page and be presented with a list of Members probably divided in to pages containing 10 results using Pagination (still need to work that out)

    Then they need to be filtered by Discipline. Say with a drop down list. "Search members by there discipline: *dropdown*" This would then return only members from that discipline. I don't mind how this works as long as its easy for the user and looks smart.
    I was advised to look at this http://api.silverstripe.org/3.0/source-class-DataObject.html#2692-2746 but i dont have the knowledge yet how to implement it.

    One last addition would be that each member when clicking their name is taken there own page displaying all their info... but this is all to come.

  • pinkp
    Avatar
    Community Member
    168 Posts

    Re: Sort GridField by Column Link to this post

    Can anyone help me create this filtering / search function for my members? Thanks

  • RuthAdele
    Avatar
    Community Member
    19 Posts

    Re: Sort GridField by Column Link to this post

    oops, I did mean to get back to you on this.

    so: search function: you know PHP right? Just write a form, set action="{$Link}/nameoffunction"
    and then have a function in your controller called nameoffunction where you do what you need to with your POST data, and return a paginated list (see below link)

    Pagination: http://doc.silverstripe.org/framework/en/howto/pagination (simple google search found this)

    You could use this module (https://github.com/arambalakjian/DataObjects-as-Pages) to make your dataobjects (i.e. the members) act as pages. which takes care of the link through to their own page bit.
    Or you could write your own version - this is an old (but good) example. http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-1-keeping-it-simple/ (some syntax might be slightly different for SS3, but essentials are the same.

    I think that covers it all. Happy coding!!

  • pinkp
    Avatar
    Community Member
    168 Posts

    Re: Sort GridField by Column Link to this post

    Thanks for your reply.

    No I don't really know PHP, I do build everything from start to finish but rely on Modules and adapting existing code and basic extensions.
    So that part is something I could really use some help or a clear example for.

    I did find the Pagination I just haven't tried using it yet.

    Data Objects as Pages doesn't seem to work for SS 3.0.5 which I'm using. Even though it states is for SS3. It doesn't seem to be compatible with the latest version so I'll need to do something different..

    I will give this tutorial a go and see where I get to.. (http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-1-keeping-it-simple/)
    but seeing as it uses DataObjectManager I will need to try the same thing with GridField.

    thanks for your guidance.

  • RuthAdele
    Avatar
    Community Member
    19 Posts

    Re: Sort GridField by Column Link to this post

    The DataObejcts as pages module does work with SS3 - I'm using it on a project at the moment.

  • pinkp
    Avatar
    Community Member
    168 Posts

    Re: Sort GridField by Column Link to this post

    Hi RuthAdele, I now have everything working using DataObjectsasPages Module its perfect. My members, their data, images, the own pages etc.
    I just need to add a search and filter to the front end. Ideally a search bar to allow generic name and content searching of the members. And also a filter system to only show results based on members Discipline in the form of radio buttons or drop down list.

    I've been looking at this: http://www.silverstripe.org/all-other-modules/show/6641?start=40

    I haven't created this before so any guidance would be great? thanks

    2203 Views
Page: 1 2
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.