|
i also have this problem (sorting the items) and don't know
how to do it
Olli
================================================== Diplom-Informatiker Oliver
Vogel Geschaeftsfuehrer
Meins und Vogel GmbH E-Mail:
[EMAIL PROTECTED] Esslinger Str. 45 Tel.:
+49 (7153)
6136-20
Fax: +49 (7153) 6136-99 D 73207
Plochingen http://www.muv.com/
Handelsregister:
Esslingen am Neckar HRB 3536 Geschäftsführer: Dipl.-Inf. Klaus
Meins
Dipl.-Inf. Oliver
Vogel ================================================== "wer
Rechtschreibfehler findet darf sie behalten"
Hello All!
how can I sort QxListItems in a
QxList?
Lets say we have a QxList with QxListItem children. My thoughts
were:
window.application.main = function()
{
var list = new QxList();
list.set({top:50,left:50});
list.add(new
QxListItem('Will'));
list.add(new
QxListItem('Anna'));
list.add(new QxListItem('Tom'));
list.add(new
QxListItem('Diana'));
list.add(new
QxListItem('Pete'));
function qxlistitemCompare
(a,b) {
var av =
a.getLabel();
var bv =
b.getLabel();
return av < bv ? -1 : ( av == bv ? 0 : 1
);
}
var btn = new QxButton('Sort');
btn.set({top:50,left:200});
btn.addEventListener('click',function(e){
var items =
list.getChildren();
items.sort(qxlistitemCompare);
for(var i=0;i<items.length;i++)
{
list.add(items[i]);
}
});
this.add(btn);
this.add(list); };
The array is sorted
correctly but the problem seems to be that re-adding the items to the list is
not enough to enforce a resorting or recreation of the items.
Any Ideas
what I have to do to make it work? 2 Cents are welcome ;-)
Thank
you.
Regards.
--
Mit freundlichen Grüßen
Dietrich Streifert
Visionet GmbH
|