cancel
Showing results for 
Search instead for 
Did you mean: 

Sort the Valuenode records in table

Former Member
0 Kudos

Hi Experts,

Following is the code I wore to retrive and display Portal roles in a table. The context maintained is as follows and got the results properly. I want to know how to sort the table values by Role_Name?. Could some one help me?

[Value node] Role_table

[Value Attribute] RoleID

[Value Attribute] Role_Name

[Value Attribute] PCD_Location

//Retrive the roles from the Role factory

String[] theroles = rolefact.getRolesOfUser(unique_id,true);

for(int i=0; i<theroles.length; i++ )

{

//Retrive user attributes and add to the context attribute values

String roleid = rolefact.getRole(theroles<i>).getDisplayName();

String rolename = rolefact.getRole(theroles<i>).getDescription();

String role_desc = rolefact.getRole(theroles<i>).getUniqueName();

IPrivateUserView.IRole_tableElement rowelement = wdContext.createRole_tableElement();

rowelement.setAttributeValue("RoleID",roleid);

rowelement.setAttributeValue("Role_Name",rolename);

rowelement.setAttributeValue("PCD_Location",role_desc);

//Append the roles obtained and bind to the rolenode

al.add(rowelement);

wdContext.nodeRole_table().bind(al);

}

Please help me with some code on how to sort the value node table?. I promise to award the points for the right solution. I appreciate coding help.

Thank you

Regards

Maruti

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Maruti,

1. Get the size of the node, save it in a variable say <b>si</b>

int si = wdContext.nodeRole_table().size();

2. Iterate as follows

for(int i=0;i<si;i++)    
    { 
     for(int j=i+1;j<si;j++)
       {
         if(wdContext.nodeRole_table().getRole_tableElementAt(i).getAttributeAsText("Role_Name").compareToIgnoreCase(wdContext.nodeRole_table().getRole_tableElementAt(j).getAttributeAsText("Role_Name"))<0)
         wdContext.nodeRole_table().swapElements(i,j);
       }
    }

Regards,

Mathan MP

Former Member
0 Kudos

Hi Mathan,

Thank you for your reply. I want to display complete table based on sorted Role_Name . I am not sure how to code this. Can you please pass code.

Thank you

Regards

Maruti

Former Member
0 Kudos

Add the following line of code after the loop that fills the node:

wdContext.nodeRole_table().sortElements
(
  new Comparator()
  {
    public int compare(Object x, Object y)
    {
      IRole_tableElement rx = (IRole_tableElement) x;
      IRole_tableElement ry = (IRole_tableElement) y;
      if (rx == null) return ry == null ? 0 : 1;
      return rx.getRole_Name().compareTo( ry.getRole_Name() );
    }
  }
);

Armin

Former Member
0 Kudos

Hi Armin,

Thank you so much for the help. Its sorted now

Regards

Maruti

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi, I'm becoming mad with filter actions in Web Dynpro table!

Can you help me!?!

I'm asking you for help me to implement a filter in a Web Dynpro table: I trying to do it without any kind of success!

All tutorials, I tried/downloaded from SDN, don’t work!

The table is visible at runtime with the filter icon and insert field…. But if I insert a simple letter “a” in the field and press the filter button/icon, it doesn't happen anything And this happen with every tutorial!

Maybe, I’m not right understanding the filter structure?!?!? I don’t know!

Could someone help me showing me a simple and quick way to exit from this caos?

Tnx in advance

Enrico (Italy)

Former Member
0 Kudos

I have not tried filtering. But I though to send you some info for you. Hope this helps

<u>SAP Network Blog: Generic Web Dynpro Java Table Filter</u>

/people/peter.vignet/blog/2007/01/03/generic-web-dynpro-java-table-filter

Former Member
0 Kudos

Hi,

Check the below blogs for table sort and filter,

Bertram Ganz blogs,

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

Kapil weblogs:

/people/kapil.kamble/blog/2006/12/21/how-to-get-ready-made-filter-for-your-web-dynpro-table-with-minimal-coding

Subramaniyan :

/people/subramanian.venkateswaran2/blog/2005/05/10/filtering-table-values-using-webdynpro

Regards,

Suresh.T

former_member182372
Active Contributor
0 Kudos