Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Sorting a DataObjectSet and ignoring upper- and lower-cases

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1198 Views
  • FlorianH
    Avatar
    Community Member
    33 Posts

    Sorting a DataObjectSet and ignoring upper- and lower-cases Link to this post

    Hey there,

    I wonder if there is any method to sort a DataObjectSet by a Varchar field and ignore upper- and lower-cases. I just recognized that sorting puts the words with a lower-case at the end of the list which is not the way I wanna use the sort. Ideas anyone? Thanks in advance.

    FlorianH

  • FlorianH
    Avatar
    Community Member
    33 Posts

    Re: Sorting a DataObjectSet and ignoring upper- and lower-cases Link to this post

    I still didn't make it. If no ones got an idea, I need to write an own sort method, but I got some problems with it. Is there any method to change to items in a DataObjectSet?

  • FlorianH
    Avatar
    Community Member
    33 Posts

    Re: Sorting a DataObjectSet and ignoring upper- and lower-cases Link to this post

    I just searched in the whole SS-Code wo get some more information about the iterator and how it should be used, but I just don't get it. If someone used it in his code, a Example Loop would be really nice. Thanks in advance

    FlorianH

    EDIT:

    I tried something like this:

    while($someDataObjectSet->getIterator()->next())
    {
    // ...do Stuff
    $someDataObjectSet = $someDataObjectSet->getIterator()->next();
    }


    But that won't work obviously since the "next()" function returns a DataObject instead of a DataObjectSet. Thats why I got trouble with the whole iterating thing ;)

    EDIT2:

    Actually that was a bad example since it's the same like "foreach($someDataObjectSet as $someDataObject)", so I try to be more specifically. I need the iterate method to check if there is another DataObject right behind the current DataObject in the foreach loop. Any ideas?

    1198 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.