cancel
Showing results for 
Search instead for 
Did you mean: 

Table Filter

Former Member
0 Kudos

Greetings,

I am currently using a Web Dynpro Table element and am trying to implement a filter mechanism on a TableColumn. All the functionality appears to be there in the API, but I am unsure about how to implement such a filter. Does anyone have any examples on how to implement this? Any help is MUCH appreciated.

Thanks,

Dustin

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Try the following:

Build a Context-Structure:

Element myGroup(Cardinality 1:1)

|--Element myTable(Cardinality 0:n)

| |--AttributeA

| |--AttributeB

|--Element myTableFilter(Cardinality 1:1)

| |--AttributeA

| |--AttributeB

The source for your table is the "myTable"-Element.

Each table-column has a "filterValue"-Property; bind this Property to the corresponding Attribute of the ContextElement "myTableFilter".

After you have done this, your table automaticly has a "filter-row" as first row, in which a user can insert some filter-values. These filter-values are stored in your Context-Element "myTableFilter".

The table has an event "onFilter" (when a user clicks on the filter-icon of the table). Create and assign a method to this Event, for example "myTableFilterPressed". Within this methode you can implement your filter-logic.

For Example, if your Context-Attribute is of type String, you could use the "indexOf"-methode in your filter-logic.

Remember, that the filter-values a user has entered are stored in your context, so you have everything you need.

Basicly you have to reinitialize your Context-Elment "myTable"; you bind only this table-entries, which have passed your filter-logic.

The last line of your code would look like this:

wdContext.nodeMyGroup().nodeMyTable().bind(filteredElements);

Hope that helps,

Josef

0 Kudos

Hi Josef,

Do you know a solution for reset the Filter in a table?

Actually you advice to bind the table content with filtered elements:

The last line of your code would look like this:

wdContext.nodeMyGroup().nodeMyTable().bind(filteredElements);

BUT Do you know :

How to get the original content

Suppose this scenario: User filter the table and then remove the filter condition in the first row - ( somehow exclude the filter)

One solution that I see is to backup the content of node before filtering in other context node

Do you know other solutions?

Do you have some examples?

Do you know in WD environment some prepared filtered functions?

(For example in Advanced Value Help table there is a default filter that work fine for String type with all wildcards (*, ? and so on)

Thanks in advanced

Rosen

Former Member
0 Kudos

Hi Rosen,

(at least I do it the following way, there may be better solutions...)

After having initially loaded the data from the backend, I keep a reference to all available instances in a container, for example in a "java.util.Vector".

For my previous example I would instantiate two variables in the "begin others"-section of the WebDynproController.

<b>protected Vector loadedMyTableElements = new Vector();

protected Vector myTableElementsToDisplay = new Vector();</b>

The Vector "loadedMyTableElements" I fill when initially loading all data from the Backend-System, and I don't touch it anymore.

In the Vector "myTableElementsToDisplay" I only keep references to Elements I want to display:

- as long as no filter is applied, the Vector "myTableElementsToDisplay" has the same content as "loadedMyTableElements"

- if a filter is applied, this Vector contains only a subset.

Finally I use the Vector "myTableElementToDisplay" within the method

<b>wdContext.nodeMyGroup().nodeMyTable().bind(myTableElementsToDisplay);</b>

When you want to reset your filter, you fill your Vector

"myTableElementsToDisplay" with all instances of your loadedMyTableElements:

<b>myTableElementsToDisplay().clear();

myTableElementsToDisplay().addAll(loadedMyTableElements);</b>

And call

<b>wdContext.nodeMyGroup().nodeMyTable().bind(myTableElementsToDisplay);</b>

again.

In this way

- you don't have to load the data from the backend again, and

- it does not need much memory, because you only store reference to the same "element-instances" in your two Vectors.