cancel
Showing results for 
Search instead for 
Did you mean: 

Sort Table in Webdynpro Java

Former Member
0 Kudos

Hi Expert,

I have created a table in Webdynpro Java with 2 columns NAME , AGE with rows values as (ABC,16 and XYZ 20) The requirement is when user click on any of the column that column should sort in ascending or descending order. Eg. If I click on NAME, rows should be (ABC,16 and XYZ 20), on again clicking NAME column, rows should display (XYZ 20 and ABC 16). Similarly, when I click on AGE it should sort the rows in ascending or descending order based on age values.

I found the solution, where JAVA CLASS for Table Sort has been used.

I do not want to use this JAVA CLASS, please help

Regards,

Khushboo

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Luis,

I am using NWDS 7.1.

I already tried with JAVA Class but that is not working. Its giving me arrows on the column but not sorting it on click.

zehiro
Explorer
0 Kudos

Hi, Khushboo

try this in sort event

SorterScn sorter = new SorterScn();

wdContext.nodeNodoscn().sortElements(sorter);

and add this class to your code

  public class SorterScn implements Comparator<IWDNodeElement>{

          

@Override

          public int compare(IWDNodeElement o1, IWDNodeElement o2) {

  // TODO  Add parameters to compare byName or By Age

                    return o1.getAttributeAsText("Name").compareTo(o1.getAttributeAsText("Name"));

 

          }

  }

Former Member
0 Kudos

If the table is dynamically populated what should be done, I have a link to tutorial which shows how to insert sorting .

http://scn.sap.com/people/peter.vignet/blog/2007/01/03/generic-web-dynpro-java-table-filter

But if the table is not in the View and it is dynalically inserted using code, What shouldbe done ?

Please help.

Answers (4)

Answers (4)

Former Member
0 Kudos

Sorry for late reply..

That requirement got cancelled.

junwu
Active Contributor
0 Kudos

why not use that one?

zehiro
Explorer
0 Kudos

hi, which version of netweaver are you running  ?

Former Member
0 Kudos

You can archive this sorting by use the table sorter classes only.