on 09-07-2007 9:30 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi sayan,
onSort event is already available for the tables.use that & put ur sorting code inside that event handler.
regards
Sumit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhilash,
Thanks for the suggestion. It would be really great if u can explain a bit in details... like what is a comparator??? and where to write this piece of java coding???... do i need to create a separate java file and add it to my package??? if so... where to create the java file... in netweaver itself ??? etc.. etc...
Actually I am new to webdynpro... so do not know these concepts in details...
Thanks,
Sayan
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
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.