Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>i my case, i did my sorting like this:</p> <pre><code>private void sortColumn( List&lt;CModel&gt; list ) { int count = listOfColumns.size(); //upon adding the columns, i have created a list that will hold all the columns if ( list.size() &lt;= 0 ) { for ( int i = 0; i &lt; count; i++ ) { listOfColumns.get(i).setSortable( false ); } } else { for ( int i = 0; i &lt; count; i++ ) { sort( i ); dg.redrawHeaders(); } } } private void sort(int i) { String[] listColHead = { /** list of column headers */ }; Column&lt;CModel,?&gt; column = listCheckoutColumns.get( i ); final String valueToCompare = listColHead[i]; final ListDataProvider&lt;CModel&gt; dataProvider = new ListDataProvider&lt;CModel&gt;(); // Connect the table to the data provider dataProvider.addDataDisplay( dg ); // Add the data to the data provider, which automatically pushes it to the widget List&lt;CModel&gt; list = dataProvider.getList(); for ( CModel product : listCheckout ) { list.add( product ); } column.setSortable( true ); // Add a ColumnSortEvent.ListHandler to connect sorting to the List ListHandler&lt;CModel&gt; columnSortHandler = new ListHandler&lt;CModel&gt;( list ); columnSortHandler.setComparator( column, new Comparator&lt;CModel&gt;() { public int compare( CModel p1, CModel p2 ) { if ( p1 == p2 ) { return 0; } // Compare the columns. if ( p1 != null ) { if ( valueToCompare.equals( "code" ) ) { return ( p2 != null ) ? p1.getFproductid().compareTo( p2.getFproductid() ) : 1; } else if ( valueToCompare.equals( "desc" ) ) { return ( p2 != null ) ? p1.getFproduct_name().compareTo( p2.getFproduct_name() ) : 1; } else if ( valueToCompare.equals( "type" ) ) { return ( p2 != null ) ? uec.computeTypeLabel( p1 ).compareTo( uec.computeTypeLabel( p2 ) ) : 1; } else if ( valueToCompare.equals( "maxex" ) ) { return ( p2 != null ) ? uec.exQtyLabel( p1 ).compareTo( uec.exQtyLabel( p2 ) ) : 1; } else if ( valueToCompare.equals( "unit" ) ) { return ( p2 != null ) ? p1.getFuom().compareTo( p2.getFuom() ) : 1; } else if ( valueToCompare.equals( "status" ) ) { return ( p2 != null ) ? uec.qtyLabel( p1 ).compareTo( uec.qtyLabel( p2 ) ) : 1; } else if ( valueToCompare.equals( "qty" ) ) { return ( p2 != null ) ? Double.compare( p1.getFqty(), p2.getFqty() ) : 1; } else if ( valueToCompare.equals( "price" ) ) { return ( p2 != null ) ? uec.extPriceLabel( p1 ).compareTo( uec.extPriceLabel( p2 ) ) : 1; } else if ( valueToCompare.equals( "total" ) ) { return ( p2 != null ) ? Double.compare( p1.getFtotal_line(), p2.getFtotal_line() ) : 1; } } return -1; } }); dg.addColumnSortHandler( columnSortHandler ); dg.getColumnSortList().push( column ); } </code></pre> <p>everytime, i'll set the data for my DataGrid list,</p> <pre><code> dgCheckout.redraw(); dgCheckout.setRowCount( lengthOfList, true ); dgCheckout.setRowData( 0, newList ); sortColumn( newList ); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload