Dietrich Streifert schrieb:
Here It is and SOLVED:
Please have a look at the List_4.html example attached to the mail.
The trick is to NOT sort the children array. A new array is built upon
the sort criteria (eg. the label or the value of the item) which holds a
reference to the child item.
Just my 2 cents:
It was a really bad idea to sort the array which is accessed through a
getter. As javascript always references to this array, also if you
modify it, you will override many qooxdoo internals (and probably broke
them) this way.
Then this new array is sorted and after that the items are re-added in
the new order by callint the addAtEnd method of the QxList.
addAtEnd is IMHO a bit complex. Normally you does not need to re-add
them (ok, qooxdoo does not really will re-add them, as it compares the
old and new parent before), but there is currently unfortunately no
other way to solve this. I hope the overhead is not to big.
addAtEnd is a bit to complex because it always need the current length.
Normally you will use a loop to refill the children to the parent.
Possible you can alternativly does something like this:
for (var i=0, a=sortedChildren, l=a.length; i<l; i++) {
myParent.addAt(a[i], i);
};
This should be a small time faster. If we need something like this
sorting more often we should thought about a more optimized way to
refresh such widgets.
Sebastian
I created three new methods for QxList:
1) internal _sortItemsCompare method for sorting comparison
2) sortItemsByString() which sorts asc/desc by the getLabel() value
3) sortItemsByValue() which sorts asc/desc by the getValue() value
Should I put the new methods into QxList and create a patch for QxList?
------------------------------------------------------------------------
QxList Item Sorting demo
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel