beehive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xiao jing <>
Subject about data sorting in DataGrid
Date Thu, 13 Oct 2005 03:34:48 GMT
    i have a JavaBean User defined like:
package org.vivianj.beehive.examples;
	public class User implements java.util.Comparator{
		private  String name;
		private String password;

		public void setName(String name) { = name;}
		public void setPassword(String password) {this.password = password;}
		public String getName() { return;}
		public String getPassword(){ return this.password;}

		public int compare(Object o1, Object o2) {
			User user1 = (User)o1;
			User user2 = (User)o2;
			String name1 = user1.getName();
			String name2 = user2.getName();
			return name1.compareTo(name2);
		public boolean equals(Object obj){
			User user = (User)obj;
			if(user.getName().equals( return true;
			else return false;

 then i create 100 User objects.

ArrayList list = new ArrayList();
  for( int i = 0;i<100;i++){
	  User user = new User();
	  user.setName("user" + (100 - i));
	  user.setPassword("pass" + i);



then i use DataGrid to show these objects like :

<netui-data:dataGrid dataSource="users" name="datausers">
         <netui-data:configurePager disableDefaultPager="true" 
pagerFormat="firstPrevNextLast" pageSize="20"/>
             <netui-data:headerCell value="用户名" sortExpression="name"/>
             <netui-data:headerCell value="密码"/>

             <netui-data:spanCell value="${}"/>
             <netui-data:spanCell value="${container.item.password}"/>
			<td colspan="2"><netui-data:renderPager/></td>

everything is ok except that the sortExpression do not work well,some
one has good ideas?
View raw message