on 2013 Jan 04 11:50 AM
Hi Experts,
I have a table which displays mdm data and i want the table to be sorted be default based upon a column when ever table screen is loaded.
Can some one help me with steps what to do and how to use or change the tablesorter class for this requirement
Thanks,
Anusha
Hello Anusha,
1.Go to the Table Properties
Table--->table column---->sortstate-->
2.Create one context attribute type with TableSorter
3.add TableSorter.java file under src/packages/util
http://wiki.sdn.sap.com/wiki/display/devchallenge/TableSorter.java+For+WebDynpro
4.add the below code in the wddomodify view
if (firstTime){
IWDTable documentListTable = (IWDTable) view.getElement("<table id>");
wdContext.currentContextElement().setTableSorter(
new TableSorter(documentListTable, wdThis.wdGetSortDocumentListAction(), null, new String[] { "<column name>" }));
wdContext.currentContextElement().getTableSorter().sort_force("<column name>","sortstate",wdContext.nodeIt_Docs());
wdContext.currentContextElement().setTableSorter(
new TableSorter(documentListTable, wdThis.wdGetSortDocumentListAction(), null));
wdContext.currentContextElement().setRows(0);
Regards,
Manivannan P
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Manivannan,
Thanks for the quick response.
Can you please give in more brief way as i do not understand
wdContext.currentContextElement().getTableSorter().sort_force("<column name>","sortstate",wdContext.nodeIt_Docs());
i do not have any sort_force method in my tablesorter class and also u are passing column name to the tablesorter class.What changes do we need to do in table sorter class for adding column name also in parameter,
Thanks,
Anusha
Hello,
This is the custom method from the Tablesorter.java. You can use existing method or create custom method based on your sorting
eg:
public void sort_force(String Column,String Direction, IWDNode dataSource) {
// find the things we need
String columnId = Column;
String direction = Direction;
IWDTableColumn column = (IWDTableColumn) table.getView().getElement(columnId);
NodeElementByAttributeComparator elementComparator = (NodeElementByAttributeComparator) comparatorForColumn.get(column);
if (elementComparator == null){
//not a sortable column
column.setSortState(WDTableColumnSortDirection.NOT_SORTABLE);
return;
}
// sorting
elementComparator.setSortDirection(WDTableColumnSortDirection.valueOf(direction));
dataSource.sortElements(elementComparator);
}
Regards,
Manivannan P
Hi,
If you follow the above steps it should be an sort state. Please check once again.
Please check the code in wdDomodifyiew again
Syntax:
wdContext.currentContextElement().getTableSorter().sort_force("<column name>","sortstate",wdContext.nodeIt_Docs()); |
Eg:
wdContext.currentContextElement().getTableSorter().sort_force("Status","up",wdContext.nodeIt_Docs());
also define in the Table column property-->sortstate
Regards,
Manivannan P
User | Count |
---|---|
81 | |
11 | |
10 | |
10 | |
10 | |
8 | |
7 | |
7 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.