cancel
Showing results for 
Search instead for 
Did you mean: 

Need to sort boolean-value column, displayed by icons

Former Member
0 Kudos

Hi,

in a WD Table i have a column that contains boolean values, and this bools are dislayed by two icons (calculated attributes that give back the file "yes.gif", "no.gif").

And i have to sort this values.

Is it possible??

The other columns have StringValues, and are sorted with the TableSorter-Class posted in blog.

Regards,

Bernhard

Edited by: Bernhard Derks on Mar 5, 2008 8:29 AM

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

IIRC the TableSorter class offers the possibility to pass explicit comparators for table columns. Implement a comparator for the icon column that compares two node elements according to the boolean value that defines the icon and pass this comparator to the TableSorter.

Something like


Context
+ Rows (node)
   + booleanValue (boolean)
   + icon (string)

Comparator compareRowsByBooleanValue = new Comparator()
{
  public int compare(Object x, Object y)
  {
    IRowsElement rx = (IRowsElement) x;
    IRowsElement ry = (IRowsElement) y;
    if (rx.getBooleanValue() == ry.getBooleanValue())
      return 0; 
    return rx.getBooleanValue() ? -1 : +1;
  }
}

Armin

Former Member
0 Kudos

Hi Bernhard,

I have an Idea. Why don't you have one more attribute in the table node of string type carrying "0" for false and "1" for true which should be set while setting the images in the boolean column. Now onAction (instead of onSort as we don't have any for the column) use the code for context node-sorter based on this string attribute.

For node-sorting of attributes not bound to the table follow the link where Node Sorter class is given. Also, how to call it in your web dynpro application for sorting based on particular attribute is given.

[Context Node Sorting|http://wiki.sdn.sap.com/wiki/display/Snippets/SortingContextNode]

I know it is not the exact solution but of course is the closest match I can see. The only difference would be we wont have sorting icon next to the column header for sorting. Instead you would have to just click the column header. What do you say?

Regards,

Tushar SInha

roberto_carini
Explorer
0 Kudos

Hi!

have you solved ??

I have same problem...

thanks!

Roberto

Former Member
0 Kudos

Hi bernhard,

U can check this.Here he is using it for filter but u can try for sort as well.few things need to be changed.

/people/peter.vignet/blog/2007/01/03/generic-web-dynpro-java-table-filter

regards

Sumit

Former Member
0 Kudos

Hi,

You can do this by making use of your own comparator.

Regards

Ayyapparaj