Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to select row in ALV grid

Former Member
0 Kudos

In my handler for the DOUBLE_CLICK event of the ALV, I would like to highlight a particular row in the grid by selecting it. I have tried various combinations of SEL_MODE in the layout, and using the SET_SELECTED_CELLS, SET_CURRENT_CELL_VIA_ID and SET_SELECTED_ROWS methods but none seem to have any effect. My event handler does a cl_gui_cfw=>set_new_ok_code method in order to force PBO processing, if you think that might make a difference.

Ideally, I would like to select the entire row in order that it is visually obvious to the user which row is currently selected. Do you have any ideas or example programs of how to do this?

Thanks,

Jim

1 ACCEPTED SOLUTION

VXLozano
Active Contributor
0 Kudos

You only set the information, did not show it.

Try to call the REFRESH_TABLE_DISPLAY method after set your selected cells.

Wish it works,

Vic

9 REPLIES 9

VXLozano
Active Contributor
0 Kudos

You only set the information, did not show it.

Try to call the REFRESH_TABLE_DISPLAY method after set your selected cells.

Wish it works,

Vic

Former Member
0 Kudos

Actually I do have the refresh method being called. My code is below; the method select_row is called by my double-click event handler. No matter what cell I double-click on, my grid ends up with row 1 column 1 as the highlighted cell. I'm currently using sel_mode = "D".

method select_row.

data: lT_ROW_NO Type LVC_T_ROID,

ls_row_no type lvc_s_roid.

read table gt_split transporting no fields

with key split_id = i_split_id.

ls_row_no-row_id = sy-tabix.

append ls_row_no to lt_row_no.

  • (g_grid_split is the sender ALV instance)

CALL METHOD g_grid_split->set_selected_rows

EXPORTING

IT_ROW_NO = lt_row_no

IS_KEEP_OTHER_SELECTIONS = con_on.

g_grid_split->refresh_table_Display( ).

CALL METHOD cl_gui_cfw=>flush.

  • g_refresh_split_flg = con_on.

endmethod.

Former Member
0 Kudos

Use SEL_MODE = 'A'

Regards,

Subramanian V.

Former Member
0 Kudos

Thanks, but I still get the same result...

ssimsekler
Active Contributor
0 Kudos

Hi Jim

Check out the section <b>C.4</b> of the <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/an%20easy%20reference%20for%20alv%20grid%20control.pdf">ALV Grid Control tutorial</a> published on SDN. You may find something to help you there.

*--Serdar

Former Member
0 Kudos

Ahhhh - there was the answer:

"In your program, you may want to make some cells, rows or columns to be selected during execution. For those purposes, you can use “SET” versions of methods above whose interfaces are similar but the direction is reverse. After a screen transition, when you come back to the screen with your ALV, your selections may be lost. You can utilize “GET” methods before transition, to backup those information and after returning to the screen, you can use “SET” methods to restore them."

So I did the SET_SELECTED_ROWS method in my PBO routine and now it works.

Thanks all for your speedy help and interest! What a great forum!

Jim

ssimsekler
Active Contributor
0 Kudos

Hi Jim

Would you like to assign points regarding SDN customs?You can reward points to posts by clicking the yellow star icon at the header of each post. You can assign;

- one 10 points (solved)

- two 6 points (very helpful answer)

- many 2 points (helpful answer)

Regards...

*--Serdar

Former Member
0 Kudos

Done!

ssimsekler
Active Contributor
0 Kudos

Hi Jim

Thanks for the points. However, you should mark the question as "solved".

You can do this by checking the relevant box under the message area when you reply a message. This will give nobody 10 points but mark the thread as solved.

Or you can give someone 10 points which means that post solved the question.

My concern is not the points. But at least you can select the first choice

*--Serdar