beehive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xiao jing <vivianj....@gmail.com>
Subject about data sorting in DataGrid
Date Thu, 13 Oct 2005 03:34:48 GMT
hi,guys,
    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) {this.name = name;}
		public void setPassword(String password) {this.password = password;}
		public String getName() { return this.name;}
		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(this.name)) 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);

	  list.add(user);
  }

  request.setAttribute("users",list);

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:header>
             <netui-data:headerCell value="用户名" sortExpression="name"/>
             <netui-data:headerCell value="密码"/>
         </netui-data:header>

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

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