Skip to Content
author's profile photo Former Member
Former Member

Sort columns of a table


Is it possible to sort columns in a IWDTable object?

The column headers of a table requires a IWDCaption object, which cannot be linked to an action.

Has anyone tried to sort tables by column header before?? Is it possible??


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 10, 2004 at 10:22 PM

    IWDTableColumn has a method setOnAction(IWDAction) that associates an action with a table column. This action is triggered when the column header is clicked.

    You might also have a look at the sort()-method for context nodes.

    Regards, Armin

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 14, 2004 at 02:56 PM

    The <b>IWDNode</b> interface provides a method sortElements:

    public void  sortElements(java.util.Comparator comparator)

    <i> Sorts the elements according to the Comparator. The Comparator gets IWDNodeElements for this node. Since Collections.sort(List) is used, this sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.</i>

    The comparator has to be implemented by your own, e.g. as a separate class in folder src/packages/<package> ... / or as an inner class in your Web Dynpro controller. Assume you have declared a context value node MyData in the context of controller MyView. For sorting the contained node elements based on value attribute MyAttribute you would call

    wdContext.nodeMyData().sortElements(new MyDataComparator(sessionLocale);

    The session locale can be retrieved via


    The MyDataComparator class would look like this:

    package com.mycompany.myapp.mycomp.util;
    import java.util.*;
    import java.text.*;
    import com.mycompany.myapp.mycomp.wdp.IPrivateMyView;
    * MyComparator is used by the generic sorting-mechanism provided by IWDNode. 
    public class MyComparator implements Comparator {
    private Collator collator; 
    * Constructor for MyComparator. Need local-information for correct sorting.
    public MyComparator(Locale locale) {
    this.collator = Collator.getInstance(locale);
    * @see java.util.Comparator#compare(Object, Object)
    public int compare(Object o1, Object o2) {
    IPrivateMyView.IMyDataElement e1 = (IPrivateMyView.IMyDataElement ) o1;
    IPrivateMyView.IMyDataElement e2 = (IPrivateMyView.IMyDataElement ) o2;
    return, e2.getMyAttribute()); 

    Be aware of the fact that a Collator is used for local-specific sorting and that you have to cast the objects o1 and o2 to the generated type of your own node element (here IPrivateMyView.IMyDataElement for a View Controller named <i>MyView</i>).

    Greetings, Bertram

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.