21293 Posts in 5733 Topics by 2602 members
General Questions
SilverStripe Forums » General Questions » how to use datalist? how can you edit it? does it clone?
General questions about getting started with SilverStripe that don't fit in any of the categories above.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 176 Views |
-
how to use datalist? how can you edit it? does it clone?

21 January 2013 at 1:55pm Last edited: 21 January 2013 1:55pm
Please have a look at this:
http://www.sspaste.com/paste/show/50fc8a072fc12:
01 <?php
02
03 $myDataList = MyDataObject::get();
04
05 //option 1
06 $myDataList = $myDataList->Filter("MyField", 1);
07
08
09 //option 2
10 $myDataList->Filter("MyField", 1);
11
12 return $myDataList
13
14 // QUESTION: does option 1 return the same as 2? Is that something that is different between 3.0 and 3.1?This is a really important question. My answer is that option 1 is not the same as option 2. This surprises me and does not seem intuitive.
I would love to hear some thoughts on this.
Nicolaas
-
Re: how to use datalist? how can you edit it? does it clone?

21 January 2013 at 9:27pm
You can think of DataLists as immutable. In 3.0, this wasn't always the case (but is in this one). This means that methods that alter the representation of the list (so things like filter, exclude and sort though not things that alter the data like add and remove) return new instances of the list without changing the current variable.
-
Re: how to use datalist? how can you edit it? does it clone?

21 January 2013 at 10:12pm Last edited: 21 January 2013 10:15pm
Simon, thank you very much for the reply. Disappointing it is so unclear (not your answer, the API itself).
-
Re: how to use datalist? how can you edit it? does it clone?

22 January 2013 at 9:22am
Thanks again Simon for your answer, also see: https://github.com/silverstripe/sapphire/pull/1020 for more information.
| 176 Views | ||
|
Page:
1
|
Go to Top |
