Dietrich Streifert schrieb:
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 ;-)

try to add a locationY job to the layout queue of each child:

yourListItem.addToLayoutChanges("locationY");

I have not tried it but possible it helps with your problem.

Sebastian


Thank you.

Regards.

--
Mit freundlichen Grüßen
Dietrich Streifert
Visionet GmbH


------------------------------------------------------------------------

Introducing QxListView.

Reimplementation not completed. This is only a technical 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

Reply via email to