Grid Control Taglib - Custom Sorting Example

Sorting is one critical item when it comes to using grids to display your data. By default, our library can sort the rows of a grid using a generic algorithm. This suffices for most basic needs. However, sometimes you may wish to perform the row sorting on your own and just have the grid render accordingly.

This is now possible in version 2.0 by way of the IGridCommandEventArgs and IGridListener interfaces. In this example, we let the database do the row sorting using the standard ORDER BY SQL clause. The sort parameters are posted to the server and can be extracted out via the IGridCommandEventArgs interface. The sort parameters can then be translated into SQL. The last part is to inform the grid that the rows are already sorted. This can be done using the doCustomSort callback method.
public boolean doCustomSort(ISortContext sortContext) {
	// Tell the grid we are sorting upon the first display of the grid.
	if (isPost == false) {
           sortContext.setSortColumnNumber(sortColumn);
           sortContext.setSortType(sortType);
	}

	return true;
}
By returning true, you are telling the grid not to sort the rows. In the above example, the two setter calls are necessary since we are showing the grid as sorted when it first displays (isPost == false).

Messages
 
Id Last Name First Name Gender Zip
 
6 AAAAAAAAAA   Female 04101
  9 Parding   Male 04105
  3 arpei bag11 Male 22151
  13 Fellows Bill Male 04qwqw
  14 Warren1 danesh Male 42844
  12 Test Data Male 78723
  1 ppp gh n 6083
  8 vjvjv hjvhjv Male fghff
  7 Hogan jeff Male 04105
  4 Gardner matt Male 90210
  5 º3º matt Female 1234
  11 Grant1 paul123 Male 04106
  16 Jeyaðððð Prabhuððð Male  
  10 Danns Sam Male 04105
  2 das sonia Female 3456
  15 Prabhufdsfsd Test2 Male 321

The above grid contains 16 records.

  Download Raw Data     Download Formatted Data
 CustomSortAction.java     MyGridListenerCustomSort.java   



          Back to Samples page


home : products : pricing : company : contact us : samples : download : forums : customers

Copyright © 2000-2004 dotJ Software Inc. All rights reserved.