Hello,

I am using a SortableDataProvider with a DefaultDataTable.

>From my understanding, it seems that for every column that I wish to sort
on,   I need to add code to the iterator method of the
data provider.  None of the columns were sorting and when I added some code
in the iterator method (see below) I was able to sort on the street column.

Is this the best way to sort columns?  I am using wicket 1.3.

Thanks Karen

********iterator method from a SortableDataProvider  ************

public Iterator iterator( int first, int count )    {

        final SortParam sp = getSort();
        EventList  list = getInterruptionList();
        if ( sp.getProperty().equals("street") ){
            Collections.sort(list, new Comparator()
            {
                public int compare(Object arg0, Object arg1){
                    if ( sp.isAscending() )
                        return
((Interrupt)arg0).getStreet().compareTo(((Interrupt)arg1).getStreet());
                    else
                        return
((Interrupt)arg1).getStreet().compareTo(((Interrupt)arg0).getStreet());
                }
            });
        }
        return list.listIterator( first );
    }


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to