Ordering in Models

218 views
Skip to first unread message

nija

unread,
Aug 24, 2011, 4:20:53 AM8/24/11
to Spine
New feature wanted!
Definition order preserved in models.

For some of our models, we do complex ordering server side.
The ordering is lost client side in Opera and Chrome browsers, since
they do not respect definition order, but automatically sort on
numeric keys.

If there is a trick to preserve definition order let me know.
Otherwise it must be a general feature desired by the lots.

V/Niels

irium

unread,
Aug 24, 2011, 9:37:32 PM8/24/11
to Spine
Yes, it's definitely very needed feature. I'm also posted a question
to Stackoverflow just about this:

http://stackoverflow.com/q/7168983/347309

For now, I had figured it out by using JavaScript's Array.sort()
function, but it could much more useful if Spine.Model has support for
some sort of "sortFields" list or "sort" callback.

Erfan Imani

unread,
Aug 25, 2011, 5:39:31 AM8/25/11
to spi...@googlegroups.com
+1 :)

In Firefox, the server-side ordering is retained, unlike Chrome.

Alex MacCaw

unread,
Aug 25, 2011, 6:04:48 AM8/25/11
to spi...@googlegroups.com
Trouble is, we're storing the records in a hash (object literal) for fast ID lookups. Although it's not standardized by the spec, most browsers keep the order (I was sure Chrome did - maybe it's only the dev versions). I'm not sure of the correct solution, it's a bit of a trade off. Usually, when I want to sort the records I use the JS array.sort() function, on a callback function defined on the model. 


On Thu, Aug 25, 2011 at 10:39 AM, Erfan Imani <erfan...@gmail.com> wrote:
+1 :)

In Firefox, the server-side ordering is retained, unlike Chrome.



--
Alex MacCaw

+12147175129
@maccman

http://alexmaccaw.co.ukhttp://www.leadthinking.com | http://socialmod.com

Ivan Virabyan

unread,
Mar 29, 2012, 3:26:37 AM3/29/12
to spi...@googlegroups.com
It would be good, if a refresh() method stored ids of the records in a separate array, preserving order. Then methods like recordsValues() could iterate trough this array and pick records from hash.

Macario Ortega

unread,
Feb 25, 2013, 8:26:51 PM2/25/13
to spi...@googlegroups.com

We have encountered this issue in Chrome, I've been overriding @all and sorting using Array.sort(), but then @first and @last records are not guaranteed to be the expected ones. I imagine it is allright to override @recordsValues with a sorted.

Aaron Eischeid

unread,
Feb 26, 2013, 3:34:40 PM2/26/13
to spi...@googlegroups.com
there is some good work on this ordering issue in a branch on github. Maybe we can get that in for a 1.1 release of spine before to long. https://github.com/spine/spine/tree/chrome_order_fix 

defl...@gmail.com

unread,
Mar 30, 2013, 7:03:15 AM3/30/13
to spi...@googlegroups.com
+1 this is must have feature. Looks like very nice solution in this branch, wait eagerly for it to be released.

среда, 27 февраля 2013 г., 0:34:40 UTC+4 пользователь Aaron Eischeid написал:
Reply all
Reply to author
Forward
0 new messages