on 07-27-2006 4:19 PM
Hi,
I would like to sort columns in a table. i need the class TableSorter.java. i see the sort icon but the column do not sorted.
i need the "Developing with Tables in Web Dynpro" PDF for this implementation
have eny ideas wath is wrong
Message was edited by: Thomas Biedermann
Stefanie,
Thanks for the reply. But I'm still not getting ascending icon.
I don't know what else to check
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thomas,
I am facing similar problem. The link to the tutorial doesn't work. Or perhaps, do you still have the code, ie TableSorter.java ?
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Muhammad,
check out this blog:[Enhanced Web Dynpro Java TableSorter for SAP NetWeaver 04s|https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3287] [original link is broken] [original link is broken] [original link is broken];.
There you find links to the different versions of TableSorter: for NW2004 and for NW 7.0 also.
kind regards
Stefanie
hi,
1. i copied the TableSorter.java file to my packages folder
2. changed the package to biz.sfs.wd.mdeorders
3. i created an new Context Value Attribute TableSorter type Java Native Type TableSorter
4. defined the Table id with "TableHeaders"
5. created a new Action Sort
6. include the source code from the SDN Samples
7. deploye and run
8. the Sort Icon on the column are visible ASC and DSC but the Column are not sorted
-
<b>Code wdDoModifyView:</b>
public static void wdDoModifyView(IPrivateHeadersView wdThis, IPrivateHeadersView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
if (firstTime){
IWDTable table = (IWDTable) view.getElement("TableHeaders");
wdContext.currentContextElement().
setTableSorter(new TableSorter(table, wdThis.wdGetSortAction(), null));
}
wdThis.setLink();
//@@end
}
-
<b>Code onActionSort:</b>
public void onActionSort(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionSort(ServerEvent)
wdContext.currentContextElement().
getTableSorter().sort(wdEvent, wdContext.nodeOutput());
//@@end
}
-
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If I remember correctly, the last parameter of the TableSorter constructor (where you pass NULL) allows to pass an array of Comparator instances to help the TableSorter compare attributes with types it does not know about.
Check the source code of the TableSorter class accordingly.
A comparator for some type T can be implemented using an anonymous class, like
Comparator c = new Comparator()
{
public int compare(Object o1, Object o2)
{
T t1 = (T) o1;
T t2 = (T) o2;
/* return
- negative value if t1 < t2,
- positive value if t1 > t2,
- 0 if t1 = t2
*/
}
};
Armin
hi,
ufff....
this is complicated for me...
wath are the alternative parameter for NULL
and wherefrom received the paramter value?
and where i must include the code
Comparator c = new Comparator()
{
public int compare(Object o1, Object o2)
{
T t1 = (T) o1;
T t2 = (T) o2;
/* return
- negative value if t1 < t2,
- positive value if t1 > t2,
- 0 if t1 = t2
*/
}
};
sorry
thomas
The constructor of class TableSorter looks like
public TableSorter(IWDTable table, IWDAction sortAction, Comparator[] comparators)
The last parameter is an (optional) array of comparators for each column. If this array contains a comparator at index i, it is used to sort the table by column i.
Example: (Editor of) column 2 is bound to an attribute of type "Employee" where
interface Employee
{
public int getAge() {...}
...
}
Because the TableSorter does not know how to sort Employee objects by age, you must create a comparator and store it in the array at the column index.
/* Create an empty array */
Comparator[] columnComparators = new Comparator[<number-of-columns>];
/* Create a comparator that compares employees by age */
Comparator employeeByAge = new Comparator()
{
public int compare(Object x, Object y)
{
/* cast to used type */
Employee ex = (Employee) x;
Employee ey = (Employee) y;
/* compute and return comparison value */
return ex.getAge() - ey.getAge();
}
};
/* set array entry for column 2 */
columnComparators[2] = employeeByAge;
And this array is passed to the TableSorter constructor as the last parameter instead of NULL:
new TableSorter(table, action, columnComparators);
Effect: When you click on header of column 2, the TableSorter uses the employeeByAge comparator and the rows are sorted by employee age.
Armin
hi to all TableSorters
I downloadet the tablesorter class from the folowing link:
then i changed the TableSorter.java in my project.
Now runs the TableSorter perfectly.
best regards
Thomas
Hi to all,
Thanks for so much help....
but i do not come the far. the table am simply not sorted?!?
other one ideas?
Thomas
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.
Hi,
Try this thread
http://help.sap.com/saphelp_nw04/helpdata/en/93/6ce9403070712ae10000000a155106/frameset.htm
Regards
Saravanan K
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
i tried exactly this.
i created an new Value Attribute TableSorter with Java Native Type biz.sfs.wd.mdeorders.TableSorter
-
if (firstTime){
IWDTable table = (IWDTable) view.getElement("TableHeadersView");
wdContext.currentContextElement().
setTableSorter(new TableSorter(table, wdThis.wdGetSortAction(), null));
}
-
public void onActionSort(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionSort(ServerEvent)
wdContext.currentContextElement().
getTableSorter().sort(wdEvent,wdContext.nodeOutput());
//@@end
}
-
Regards
Thomas
Hi,
Did u add ur Tablesorter.java file in the SRC package.
If so then in the wdDoModifyView check whether u have given the correct ID of the table.
if(firstTime)
{
IWDTable table = (IWDTable)view.getElement<b>("<Table ID>");</b>
wdContext.currentContextElement().setVa_Tablesorter(new TableSorter(table,wdThis.wdGetTablesortAction(),null));
}
Refer
Regards,
Nagarajan.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.