cancel
Showing results for 
Search instead for 
Did you mean: 

Auto-Select filtered records in table element

Former Member
0 Kudos

I'm trying to automatically select all filtered records in a table UI element.

In method onactionfilter:


DATA node TYPE REF TO if_wd_context_node.
DATA lv_element_count TYPE i.  

wd_this->table_method_hndl->apply_filter( ).
node = wd_context->get_child_node( 'MAIN_DATA' ).
lv_element_count = node->get_element_count( ).
DO lv_element_count TIMES.
  node->set_selected( flag = abap_true index = sy-index ).
ENDDO.

This is doing the trick, unfortunatelly it's really selecting all of the records (even the records which are hidden due to filtering). Is there a solution how to select all rows after applying a filter (and NOT select the records which are hidden)?

Thank you in advance.

Kind Regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

After you apply the filter, set a global variable (say for e.g. an attribute in your view).

i.e.

wd_this->table_method_hndl->apply_filter( ).
wd_this->filter_on = 'X'.

Then in your WDDOMODIFYVIEW hook method write the following additional code:

DATA:  lo_table_method_hndl TYPE REF TO CL_WDR_TABLE_METHOD_HNDL,
              lt_filtered_row TYPE WDR_TABLE_ROW_DATA_TAB,
              ls_filtered_row  TYPE WDR_TABLE_ROW_DATA.

 IF wd_this->filter_on EQ 'X'.
  lo_table_method_hndl  ?= wd_this->table_method_hndl.
  lo_table_method_hndl ->get_table_data( IMPORTING row_datas = lt_filtered_row ).
  LOOP AT lt_filtered_row  INTO ls_filtered_row .
    ls_filtered_row -context_element->set_selected( flag = abap_true ).
  ENDLOOP.
 ENDIF.

This should work.

Edited by: Loveline Thomas on Oct 26, 2009 6:23 AM

Former Member
0 Kudos

Thank you very much Loveline Thomas. You're the man. Problem solved!

However, I don't need the global variable which indicated whether the filter is on or not as I always want to select all visible records.

Once again, thank you very much.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

When you have used the filter functionality, have you checked the parameters.

One thing you do, You need to get the filtered condition and based on this get the data for that node

and filter the records based on above condition and For these result set, use your code to set the element as selected

adn bind the table again.

lv_element_count = node->get_element_count( ).

Does this really return the filtered element count....

If yes, use get_elements to get the references of those elements directly and set the value selected only for these.

Have your table selection mode is set to Multi/Multi No lead to achieve the multiple elements selection.

Refer these threads -

One more thing, in CL_WD_TABLE_COLUMN have you tried using GET_ON_FILTER to get the filtered records,

for this set this as selected.

Regards,

Lekha.

Edited by: Lekha on Oct 26, 2009 2:03 PM