Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
In order to sort a column of a Web Dynpro table, a separate Java class can be used for sorting the context elements. In this scenario, there is already a special class called TableSorter available in SDN which provides this function. However, there is no special class to implement filter function on a column of a table.   In my search for this specific function, I came across Mr. Bharathwaj R's webblog on Enhancing Tables in WebDynpro Java – Custom built Table Utilities that explains wonderful features such as automatic total calculation for particular columns in a table, auto download to excel file, printing the table and generating analytical diagram of the table. But I wanted table filter function. Then I came across Mr.Subramanian Venkateswaran's blog on Filtering Table Values using WebDynpro It was very useful in understanding how a filter works in a table. But I was looking for a generic method that implements filter function on any table. Instead of searching more, I thought lets try on my own. And here I am with a web blog on it. I came up with a TableFilter java class file similar to the tablesorter class file. You can download it from TableFilter.java You have to include this java file in your Web Dynpro project source directory to make use of it. Once you have done that, please mention your Web Dynpro project package name in this file. Lets assume that you have a well-functioning table implemented in your web dynpro application and you want to have filter on a few columns of this table. Suppose this table has data source as value node 'vnTableDataSource' which is a copy of value node 'vnOriginalDataSource'. It means both the nodes contain same number of elements and have same attributes 'desc', 'dueDate', 'itemNo' and so on . These attributes are the columns of the table.  Now value node 'vnFilters' having cardinality 1..1 contains attributes 'desc', 'itemNo' and 'poNo' that are bound to the filterValue property of respective table columns. That means these columns have been made filterable. Now, context root attribute 'TableFilter' is created. It is of the type com.sap.tableproject.TableFilter   In order to trigger the filtering of columns, create an Action 'Filter' in the view.  Now, in the wdDoModifyView, enter the following code.if ( firstTime )      {           if ( null != view )            {                     IWDTable table = (IWDTable) view.getElement("Table");                wdContext.currentContextElement().setTableFilter(new TableFilter(table,wdThis.wdGetFilterAction()));           }      } And in the method 'onActionFilter' of the view, enter the following line of code     wdContext.currentContextElement().getTableFilter().filter(wdEvent,wdContext.nodeVnTableDataSource(),               wdContext.nodeVnOriginalDataSource(),               wdContext.nodeVnFilters()); Thats all. The filter has been implemented on your table. Now build your Web Dynpro project, deploy and run it. On running the application, your table will look as shown in above image. Enter your filter value and hit enter key. You can also use regular expressions to filter the records.
14 Comments