cancel
Showing results for 
Search instead for 
Did you mean: 

Table Sorting ( In Case Insensitive order)

Former Member
0 Kudos

hi,

I have a webdynpro UI Table and used the TableSort class (followed the same steps which are given in developing table example). Sorting works perfectly both ascending and descending.

But my requirement is that is should sort in case insensitive manner (presently it is happening in case sensitive manner).

Is there any option or procedure to implement this feature?

Thanks for your time and effort and I need it asap.

Best Regards,

Shiva.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Shiva,

I am guessing that you have copied the TableSorter.java file into your local workspace. In order to achieve what you want, you will need to tweak this file a bit.

Open the TableSorter.java file in edit mode and go to the following piece of code:

private static final Comparator DEFAULT = new Comparator()
  {
    /**
     * Compares the given objects according to the ordering imposed by the first
     * ones <code>compareTo(Object)</code> function. Furthermore, <code>null</code>
     * is treated to be less than any object.
     * 
     * @see java.lang.Comparable#compareTo(java.lang.Object)
     * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
     */
    public int compare(Object o1, Object o2)
    {
      if (o1 == null && o2 == null)
        return 0;
      if (o1 == null)
        return -1;
      if (o2 == null)
        return +1;
  
      return ((Comparable) o1).compareTo((Comparable) o2);
    }

Now before the <u>return</u>, add the following piece of code:

if(o1 instanceOf String && o2 instanceOf String){
   String s1 = o1.toString();
   String s2 = o2.toString();
  
   return s1.compareToIgnoreCase(s2);
}

Regards,

Satyajit.

Former Member
0 Kudos

Hi Satyajit,

Thanks for your reply and its working perfectly.

Given full points ....

Thanks a lot

Best Regards,

Shiva.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Shiva,

I am using the TableFilter and want the same functionality i.e. I want the table filter to be case insenstive. As suggested, I have added the same piece of code in my TableFilter.java file but I am unable to get the same functionality. Can you please help me with this.

Regards,

Prathamesh