on 06-18-2007 11:09 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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, dont 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, Im not right understanding the filter structure?!?!? I dont know!
Could someone help me showing me a simple and quick way to exit from this caos?
Tnx in advance
Enrico (Italy)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.