You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Darren Williams <da...@livetime.com> on 2010/10/20 14:41:25 UTC

setSortAscending on BeanModel in Grid

Hi, we have been trying to work out a way to set the default sort order on our BeanModel to descending by default, since this is what out SQL query does but it appears as though the grid does not expose this method as shown below. 

Is there another way we can do this? All the examples I have seen before 5.2 use this technique, but 5.2 has made this method private.


	public BeanModel getBeanModel() {
		//setup the model for this user
		if (beanModel == null) {
			beanModel=beanModelSource.createDisplayModel(License.class, messages);
			beanModel.include("entered","endDate");
			
			//sorting
			if (_grid.getSortModel().getSortConstraints().isEmpty() ) {
				_grid.getSortModel().updateSort("entered");
				//this is still not exposed in tapestry 5.2 so you can't change order
				//_grid.setSortAscending(false);
		    }
		}
		return beanModel;
	}

regards, Darren


Re: setSortAscending on BeanModel in Grid

Posted by Darren Williams <da...@livetime.com>.
thanks. It certainly works. Just seems like a hack for something so simple.

On Oct 20, 2010, at 9:38 AM, Josh Canfield wrote:

> If you want to you can provide a custom sort model, it's a pretty
> simple interface.
> 
> Alternatively, if all you want to do is start with sort descending
> then you could just do this:
> 
> _grid.getSortModel().updateSort("entered"); // sorts ascending
> _grid.getSortModel().updateSort("entered"); // now sorts descending
> 
> ugly, but effective.
> 
> On Wed, Oct 20, 2010 at 5:41 AM, Darren Williams <da...@livetime.com> wrote:
>> Hi, we have been trying to work out a way to set the default sort order on our BeanModel to descending by default, since this is what out SQL query does but it appears as though the grid does not expose this method as shown below.
>> 
>> Is there another way we can do this? All the examples I have seen before 5.2 use this technique, but 5.2 has made this method private.
>> 
>> 
>>        public BeanModel getBeanModel() {
>>                //setup the model for this user
>>                if (beanModel == null) {
>>                        beanModel=beanModelSource.createDisplayModel(License.class, messages);
>>                        beanModel.include("entered","endDate");
>> 
>>                        //sorting
>>                        if (_grid.getSortModel().getSortConstraints().isEmpty() ) {
>>                                _grid.getSortModel().updateSort("entered");
>>                                //this is still not exposed in tapestry 5.2 so you can't change order
>>                                //_grid.setSortAscending(false);
>>                    }
>>                }
>>                return beanModel;
>>        }
>> 
>> regards, Darren
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

_____________________
Darren Williams
LiveTime Software Inc.
http://www.livetime.com
(949) 777 5800




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: setSortAscending on BeanModel in Grid

Posted by Josh Canfield <jo...@gmail.com>.
If you want to you can provide a custom sort model, it's a pretty
simple interface.

Alternatively, if all you want to do is start with sort descending
then you could just do this:

_grid.getSortModel().updateSort("entered"); // sorts ascending
_grid.getSortModel().updateSort("entered"); // now sorts descending

ugly, but effective.

On Wed, Oct 20, 2010 at 5:41 AM, Darren Williams <da...@livetime.com> wrote:
> Hi, we have been trying to work out a way to set the default sort order on our BeanModel to descending by default, since this is what out SQL query does but it appears as though the grid does not expose this method as shown below.
>
> Is there another way we can do this? All the examples I have seen before 5.2 use this technique, but 5.2 has made this method private.
>
>
>        public BeanModel getBeanModel() {
>                //setup the model for this user
>                if (beanModel == null) {
>                        beanModel=beanModelSource.createDisplayModel(License.class, messages);
>                        beanModel.include("entered","endDate");
>
>                        //sorting
>                        if (_grid.getSortModel().getSortConstraints().isEmpty() ) {
>                                _grid.getSortModel().updateSort("entered");
>                                //this is still not exposed in tapestry 5.2 so you can't change order
>                                //_grid.setSortAscending(false);
>                    }
>                }
>                return beanModel;
>        }
>
> regards, Darren
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: setSortAscending on BeanModel in Grid

Posted by Rich M <ri...@moremagic.com>.
Hi,

I don't use 5.2, but it seems based on your code this should work (I do 
this in 5.1.0.5):

ColumnSort colSort = _grid.getSortModel().getColumnSort("txnId");

while(!colSort.equals(ColumnSort.DESCENDING)){

             _grid.getSortModel().updateSort("txnId"); //Should invert the sort

             

             colSort = _grid.getSortModel().getColumnSort("txnId");

             debug("\n\nColumnSort for txnId after one call to updateSort is: " + colSort + "\n");

}


-Rich

On 10/20/2010 08:41 AM, Darren Williams wrote:
> Hi, we have been trying to work out a way to set the default sort order on our BeanModel to descending by default, since this is what out SQL query does but it appears as though the grid does not expose this method as shown below.
>
> Is there another way we can do this? All the examples I have seen before 5.2 use this technique, but 5.2 has made this method private.
>
>
> 	public BeanModel getBeanModel() {
> 		//setup the model for this user
> 		if (beanModel == null) {
> 			beanModel=beanModelSource.createDisplayModel(License.class, messages);
> 			beanModel.include("entered","endDate");
> 			
> 			//sorting
> 			if (_grid.getSortModel().getSortConstraints().isEmpty() ) {
> 				_grid.getSortModel().updateSort("entered");
> 				//this is still not exposed in tapestry 5.2 so you can't change order
> 				//_grid.setSortAscending(false);
> 		    }
> 		}
> 		return beanModel;
> 	}
>
> regards, Darren
>
>
>    


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org