on 01-30-2006 11:41 AM
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.