cancel
Showing results for 
Search instead for 
Did you mean: 

Table Node sorting Based on Column

Former Member
0 Kudos

Hi,

I have a webdynpro table with Columns Document Name,Path,Hits. I want to sort the Table based on the Hits on descending order. I wrote a piece of code to sort it, but not getting sorted.

import java.util.Comparator;

wdContext.nodeKMAccess().sortElements(

new Comparator()

{

public int compare(Object x, Object y)

{

IPrivateDocHits1.IKMAccessElement rx = (IPrivateDocHits1.IKMAccessElement)x;

IPrivateDocHits1.IKMAccessElement ry = (IPrivateDocHits1.IKMAccessElement)y;

if (rx == null) return ry == null ? 0 : 1;

return rx.getHits().compareTo( ry.getHits() );

}

}

);

There is no error. But not getting sorted. I gave this code

wdContext.nodeKMAccess().sortElements(GenericNodeElementComparator.desc("Hits")

new Comparator()

But it is giving me an erorr. Can anyone help me out in solving this issue.

Regards,

Divya

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Divya,

Use this

<a href="/people/bertram.ganz/blog/2006/03/07/enhanced-web-dynpro-java-tablesorter-for-sap-netweaver-04s:///people/bertram.ganz/blog/2006/03/07/enhanced-web-dynpro-java-tablesorter-for-sap-netweaver-04s

regards

Sumit

Former Member
0 Kudos

Hi,

I dont want to use table Sorter. Can i acheive by using Comparator().

Does anyone have code samples regarding this?

Regards,

Divya

Former Member
0 Kudos

Hi,

Your comparator looks alright. Have you done all the action mappings properly? For e.g. the onSort event of the table and the onAction event of the table column.

Regards,

Satyajit.

Former Member
0 Kudos

Hi,

Thanx for the reply. But what is that onSort event of the table and the onAction event of the table column? I want the table to be sorted in descending order automatically based on that column when the project runs. For that why should i give an action to the table.

Sorry if what i ask is wrong.

Regards,

Divya

Former Member
0 Kudos

Hi ,

I have downloaded the zip file for the TableSorter Class. I have added all the necessary codes for sorting a table. ut it is showing me an error.

"import com.sap.tc.webdynpro.test.utils.TableSorter". cannot be resolved or not a type.

What jarfile should i import for this? The only error is this.What jarfile should i import for this?

Regards,

Divya

Former Member
0 Kudos

Hi Divya,

No jar file is required for that. Opent the java file & change the package name over there.

regards

Sumit

Former Member
0 Kudos

Hi,

Thanx for the reply. I learnt that table sorter application was developed in NWDS 04. But i am working in NWDS 02. Will The table sorter be supported in NWDS02.??

Regards,

Divya

Former Member
0 Kudos

Hi Divya,

I don't think so.

regards

Sumit

Former Member
0 Kudos

Hi,

I have already imported Table Sorter into my webdynpro project.

project - import - zipfile . (into project-src-packages-com-Table Sorter).

In the code it shows that (com.sap.tc.webdynpro.tests.utils.TableSorter cannot be resolved error). Please Let me know how to fix it.

Regards,

Divya

Former Member
0 Kudos

Hi Divya,

U have imported the complete project itself . u need to copy only the TableSorter.java file in ur package. change the package & use it in ur project.

regards

Sumit

Answers (0)