cancel
Showing results for 
Search instead for 
Did you mean: 

How to use a FILTER in a normal table in ABAP WEB DYNPRO

Former Member
0 Kudos

Hi Experts,

I need to Filter my table in UI using the 'onFilter' event,

BUT I want the first row of the table to be my INPUTS to do the filtering - JUST LIKE IN ALV TABLE,

since i dont want to use an ALV table, i want the same to be done in a transparent table...

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Dear pramodh,

Here u can achieve filter option in transparent table by creating a button(Toggle) in table.

1.Now you need to apply filter in OnToggle event.

wd_this->table_control->apply_filter( ).

2.when the Filter button is pressed IS_FILTER_ON attribute will turn ON and FILTER will be set.

And Automatically the First row is set for INPUTS.

The Following Code is required to get Handler for Table and also to SET FILTER.

method WDDOMODIFYVIEW .

DATA: wd_table TYPE REF TO cl_wd_table,

w_is_filter_on TYPE wdy_boolean.

wd_context->get_attribute( EXPORTING name = 'IS_FILTER_ON'

IMPORTING value = w_is_filter_on ).

wd_table ?= view->get_element( '<give ur table ID>' ).

wd_this->table_control ?= wd_table->_method_handler.

IF w_is_filter_on = abap_true.

wd_table->set_on_filter( 'FILTER' ).

else.

wd_table->set_on_filter( '' ).

ENDIF.

endmethod.

I believe u know about Table Handler. And i can help if u need.

Thanks & Regards,

Rakesh Vanamala.

Former Member
0 Kudos

Hi Rakesh,

I do not know about table handlers, hence the statement

'wd_this->table_control->apply_filter( ).' is giving an error:

Field "TABLE_CONTROL->APPLY_FILTER(" is unknown. It is neither in one

of the specified tables nor defined by a "DATA" statement. "DATA"

statement.

and i do not find the onToggle event too...

i find only events like:-

onFilter , onLeadSelect , onScroll , onSort

can u help me in that too..

thank you in advance..

ChrisPaine
Active Contributor
0 Kudos

You will need to define the table handler as an attribute of your controller/view (this is so that it can be referenced outside of the WDDOMODIFYVIEW).

it should be a type ref to IF_WD_TABLE_METHOD_HNDL.

the onToggle event is available if you create a toggle button (which can be useful for showing/hiding filters).

This blog [which is about using the table handler for sorting|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/6979] [original link is broken]; might help you as it covers many of the same steps as implementing your own filter.

Former Member
0 Kudos

Pramoth,

table_control is an attribute in order to access methods in the interface IF_WD_TABLE_METHOD_HNDL.

1. First u define table_control for interface IF_WD_TABLE_METHOD_HNDL in ATTRIBUTES Tab of Current View.

2.Create a Button on table in layout with type ToolBarToggleButton . Now u will be able to get OnToggle Event in properties of ToggleButton.

3.Now You can create an event in OnToggle and write following code

wd_view->table_control->apply_filter() can be written.

It will work now.

Let me know if u have any queries..

Thanks & Regards,

Rakesh Vanamala.

0 Kudos

Hi Rakesh,

I have seen your post on column filter in transparent table. I also have the similar requirement and when I followed the steps you have provided, it is giving error that 'IS_FILTER_ON' attribute is not found.

Following are the steps I have followed:

1. Defined 'TABLE' attribute type ref to IF_WD_TABLE_METHOD_HNDL.

2. Created a Tool Bar element on Table with its Visible attribute to none.

3. Created a ToolBarToggleButton element on Toolbar.

4. Defined a method for event 'ONTOGGLE' with following code

METHOD ONTOGGLE.

wd_this->table->apply_filter( ).

ENDMETHOD.

5. Method WDDOMODIFYVIEW.

DATA: wd_table TYPE REF TO cl_wd_table,

w_is_filter_on TYPE wdy_boolean.

wd_context->get_attribute( EXPORTING name = 'IS_FILTER_ON'

IMPORTING value = w_is_filter_on ).

wd_table ?= view->get_element( 'TABLE' ).

wd_this->table ?= wd_table->_method_handler.

IF w_is_filter_on = abap_true.

wd_table->set_on_filter( 'FILTER' ).

else.

wd_table->set_on_filter( '' ).

ENDIF.ENDMETHOD.

I have 5 rows in table and when I click on filter button, nothing is happening i.e, I am not getting a input field to filter the entries. Kindly help.

0 Kudos

Hi sachin,

At present I am facing the same problem, If u solve this problem, please share the code details and all.

(Filter problem)

thanks and regardss.

Former Member
0 Kudos

see sample DEMO_TABLE

Former Member
0 Kudos

Hi everyone,

You shall create an attribute IS_FILTER_ON of type WDY_BOOLEAN or BOOLEAN in the context of the view or component controller.

As you can see the code above checks the value of this attribute.

When you want to apply filter, make this attribute ABAP_TRUE. In this case filter is applied.

When you want to remove filter, make this attribute ABAP_FALSE. In this case, filter is removed.

One more thing that u must take care for above code is that the action you create for OnFilter event of table should be named FILTER because in set_on_filter method you are paasing the action name as 'FILTER'.

Former Member
0 Kudos

Hi,

You can use the filter option in Normal table UI as well and when you switch the filter on you will get the option for input in the first row itself...

you do not have to do anything for that.

Thanks

Pradeep