cancel
Showing results for 
Search instead for 
Did you mean: 

Reset the table filter and Sort functionality in webdynpro abap

Former Member
0 Kudos

Hello Gurus,

I have created a table and added filter and sort functionality using DEMO_TABLE application.

Filter and sort is working fine as expected. now, i have created a button(BACK) to go back to selection screen to search again with the new selection screen values.

whenever i click on (BACK) button, how can i reset the filter and sort on table.

I'll update the table context when the user clicked on "Search" button on the first view. once the table is updated with the new data, user can able to filter and sort again.

Can anyone please let me know how to reset the filter & sort functionality up on back button action (Second View) or Search button action (First View).

Little urgent! Points will be rewarded!

Thank You.

Shyam

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You can try the following:

1. Get the reference of your table in the view in method WDDOMODIFYVIEW.

2. Pass this to a global variable.

3. No when the user presses back call method SET_ON_FILTER of class CL_WD_TABLE with your table reference stored in the global variable in step2.

4. Pass space as parameter to this method.

Also do not forget to clear the node that holds filter information.

Hope this helps.

Former Member
0 Kudos

Hi Kushboo,

I have written the below logic in WDDOMODIFYVIEW.

   DATA: l_table TYPE REF TO cl_wd_table,
        l_is_filter_on TYPE wdy_boolean.

* Find out whether filter is on
  wd_context->get_attribute( EXPORTING name = 'IS_FILTER_ON'
                              IMPORTING value = l_is_filter_on ).

* Get reference of the table view element
  l_table ?= view->get_element( 'TABLE' ).

* Get reference to the Filter & Sorting API
  wd_this->table_control ?= l_table->_method_handler.

* Set or cancel the table's filter action
  IF l_is_filter_on = abap_true.
    l_table->set_on_filter( 'FILTER' ).
  ELSE.
    l_table->set_on_filter( '' ).
  ENDIF.

If i create a global variable in Component Controller, Can you please let me know what value do i have to pass to the global variable?

I have called the method CL_WD_TABLE->SET_ON_FILTER method in BACK button and set the filter value to space. but it didn't work for me. ( I have invalidated the filter node and table node in BACK button).

Can you please give me some sample code if you have?

Thank You.

Shyam

Former Member
0 Kudos

Hi shyam,

Do the following.

1. Go to the attributes tab of your view and declare a variable L_TABLE. Check the Type Ref To Checkbox. Use type CL_WD_TABLE.

2. Go to your method WDDOMODIFYVIEW. Remove the declaration l_table TYPE REF TO cl_wd_table.

3. Now replace l_table with wd_this->l_table in the code in the method WDDOMODIFYVIEW.

4. Go to the action handler of Back Button and write the following code.

* Invalidate the filter node

  DATA: lr_node TYPE REF TO if_wd_context_node.

  lr_node = wd_context->get_child_node( 'FILTER' ).

  lr_node->invalidate( ).

* Apply Filter again

  wd_this->l_table->set_on_filter( '' ).

  wd_this->table_control->apply_filter( ).

* Call outbound plug to the first view

wd_this->fire_out_view1_plg(  ).

This works. I tried it out myself.

Former Member
0 Kudos

Thanks Kushboo...!!!

Your code really helped me a lot in resolving my issue.

Points rewarded.

Thank You.

Shyam

Answers (2)

Answers (2)

0 Kudos

In my case it was that when clicking on the button "clean" the entire screen will be cleaned.

* Resetting the filter option
wd_this->table_method_hndl->apply_filter( ).
DATA lo_nd_node TYPE REF TO if_wd_context_node.
lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_filter ). "Filter Node
lo_nd_node->invalidate( ).

Former Member
0 Kudos

in the Filter button toggle event invalidate the FILTER context and then apply the filter again , this will make it to work as intended.

Thx

Phani

Former Member
0 Kudos

Hi Phani,

Thanks for the reply...!

As you mentioned, I have invalidated FILTER Node and IS_FILTER_ON context but no luck.

Can you please let me know if there is something i am missing.

Thank You.

Shyam