The GridDataSource has control over sorting.  If you provide an
instance of GridDataSource as the source parameter, rather than a
List, you'll have the control you need.

On Wed, Jul 30, 2008 at 11:38 AM, Moritz Gmelin <[EMAIL PROTECTED]> wrote:
> OK,
>
> but then I would have to dramatically change all models I use for grids. To
> use some transient properties of the data returning CaseInsensitiveStrings
> for the actual property I wanted to display.
> I was rather hoping for some very T5-like-elegant way to either replace the
> default Comparator for certain object types. Just as I can replace the
> renderer of certain types by providing a new renderer.
>
> Any other ideas?
>
> M.
>
>
> Am 30.07.2008 um 16:30 schrieb Daniel Jue:
>
>> Here is one way to do it:
>>
>> For the object associated with the column you want to sort, you
>> override the comparable method.  I am not sure if there is an existing
>> JDK Object for  "case-insensitive String", but you could create one.
>> Overriding comparable is how you do the custom sorting.  There are
>> probably other ways of doing this.
>>
>> Stolen from the web:
>> public final class CaseInsensitiveString implements Comparable {
>>   private String s;
>>
>>   public CaseInsensitiveString(String s) {
>>       if (s == null)
>>           throw new NullPointerException();
>>       this.s = s;
>>   }
>>
>>   public boolean equals(Object o) {
>>       return o instanceof CaseInsensitiveString &&
>>           ((CaseInsensitiveString)o).s.equalsIgnoreCase(s);
>>   }
>>
>>   // Lazily initialized, cached hashCode - page 40
>>   private volatile int hashCode = 0;  // (See Item 48)
>>
>>   public int hashCode() {
>>       if (hashCode == 0)
>>           hashCode = s.toUpperCase().hashCode();
>>
>>       return hashCode;
>>   }
>>
>>   public int compareTo(Object o) {
>>       CaseInsensitiveString cis = (CaseInsensitiveString)o;
>>       return String.CASE_INSENSITIVE_ORDER.compare(s, cis.s);
>>   }
>>
>>   public String toString() {
>>       return s;
>>   }
>> }
>>
>> On Wed, Jul 30, 2008 at 6:15 AM, Moritz Gmelin <[EMAIL PROTECTED]>
>> wrote:
>>>
>>> Hi,
>>>
>>> If I wanted to change the sorting system of a grid colum. e.g ignore
>>> lower/uppercase for sorting.
>>> How could I do this?
>>>
>>> Regards
>>>
>>> Moritz
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to