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

Implementing sort function without any event

Hi All,

I want to sort a table.For this, I have added the TableSorter.java file in the package of my project. I have also made an attribute of the type TableSorter.

Now when I tried to implement the sort() function for a particular column of a table, giving all the node and column header information , I found out that an event needs to be passed as parameter in the Sort function.

I do not want the sorting of the table to be done on any event, like click of button or LinkToURL.... Instead I want the table to get sorted automatically, say in wdModifyable method itself.

How do I achieve this??? Also one more thing... Will sorting alter the arrangement of rows in the node itself or it will only display in the sorted manner????

Thanks

Sayan

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on Sep 07, 2007 at 09:00 PM

    Hi Sayan,

    The event needs not to be a Button or LinkToURL but it may be like clicking on a column header to sort the data. If you want sorting on clicking of any column then you should follow the standard way. Or if you want sorting only one time on single column then you can try this..

    - Write Comparator

    	private static class CustomComparator implements Comparator
    	{
    	  public int compare(Object obj1, Object obj2)
    	  {
    
    		IPrivate<>View.I<>Element elment1 = (IPrivate<>View.I<>Element )obj1;
    		IPrivate<>View.I<>Element elment2 = (IPrivate<>View.I<>Element )obj2;
    		
    		  return elment1.get<ColumnName>().compareTo(elment2.getColumnName());
    	  }
    	
    	  public boolean equals(Object obj) 
    	  {
    		  return false;
    	  }
    	}

    - Once you populate the data then call this method to sort data elements:

    wdContext.node<nodeName>.sortElements(new CustomComparator());

    Regards

    Abhilash

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2007 at 09:45 PM

    You can follow what maksim has suggested or change the sort method in TableSorter.java to accept columnid as the parameter instead of wdEvent. and now you can call the method from any place in your code, only thing you have to find out is the columnid by which you want to sort and pass it to this method.

    sort(String columnId, IWDNode dataSource)

    Regards

    Firasath

    Message was edited by:

    Firasath Riyaz

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2007 at 03:39 AM

    Hi sayan,

    onSort event is already available for the tables.use that & put ur sorting code inside that event handler.

    regards

    Sumit

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2007 at 03:09 PM

    Hi Sayan,

    Check this blog

    /people/bertram.ganz/blog/2006/03/07/enhanced-web-dynpro-java-tablesorter-for-sap-netweaver-04s

    Action “Sort “ it will fired when you will click on the icon beside the table headers to sort the fields in ascending / descending order. Check the blog each steps is given nicely. Separate button or link is not required for sorting.

    In Step 4: must put the table id and table fields id correctly from the outline of view layout other wise besides table header fields sorting icon will not come.

    Regards,

    Mithu

    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.