cancel
Showing results for 
Search instead for 
Did you mean: 

How can i deselect a row in the LV Grid display

Former Member
0 Kudos

Hi Experts,

I'm new to webdynpro ABAP. Can anyone give me some idea on "How can i deselect a row in the LV Grid display".

My requirement is that after selecting a row in the alv display, if i click on the same row it should be De-selected.

I wrote the following code in ON_LEAD_SELECT of the ALV.

But its giving me DUMP "Access via NULL object reference" at the CALL METHOD lr_alv->REFRESH_TABLE_DISPLAY line.

DATA lr_alv TYPE REF TO CL_GUI_ALV_GRID.

DATA lv_row_num TYPE i.

DATA: lvc_s_stbl TYPE lvc_s_stbl.

DATA: lr_index TYPE REF TO if_salv_wd_table_lead_select,

lv_line type SYTABIX.

lr_index ?= r_param.

MOVE lr_index->index TO lv_line.

lvc_s_stbl-row = lv_line.

IF lr_index->OLD_INDEX = lv_line.

CALL METHOD lr_alv->REFRESH_TABLE_DISPLAY

EXPORTING

IS_STABLE = lvc_s_stbl

I_SOFT_REFRESH = abap_true

EXCEPTIONS

FINISHED = 1

others = 2.

*IF SY-SUBRC <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*ENDIF.

ENDIF.

Canyou plz help me on this.....

Accepted Solutions (1)

Accepted Solutions (1)

saravanan_narayanan
Active Contributor
0 Kudos

Hello Shravan,

reason for hte dump is LR_ALV is not initialised. but for deselecting the selected element you can write the following code

data lo_nd type REF TO if_wd_context_node.

data lv_old_index type i.

data lv_new_index type i.

lv_new_index = r_param->index.

lv_old_index = r_param->old_index.

IF lv_old_index = lv_new_index.

lo_nd = wd_context->get_child_node( 'ALV_TABLE' ). "ALV_TABLE is the name of hte context node that is passed to the ALV component

lo_nd->set_lead_selection_index( if_wd_context_node=>no_selection ).

ENDIF.

BR, Saravanan

Answers (2)

Answers (2)

Former Member
0 Kudos

Thank u Saravanan . It solved my problem.

former_member199125
Active Contributor
0 Kudos

Hi Shravan,

If you write the code on leadselect, it will trigger when the lead of selection table changes.

If you want to deselect the selected item,

use the set_selected method with abap_false value.then it will deselect the selected record. and best to use ONCLICK event.

Regards

Srinivas