06-19-2007 12:13 PM
Hi all.
Is there a way to force my grid to have allways a selected line.
If possible I would like to see the row marker and I don't want users to be able to select more than one line.
I tried all layout sel_mode... but I didn't find the result I desire...
Do you have an idea ?
Thanks a lot
06-19-2007 5:30 PM
Hi,
check this
call method grid1->set_table_for_first_display
exporting
is_layout = gs_layout
is_variant = gs_variant
i_save = v_save
i_default = v_default
it_toolbar_excluding = i_exclude[]
changing
it_outtab = i_output[]
it_fieldcatalog = i_fieldcat[]
exceptions
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
others = 4.
if sy-subrc ne 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
call method grid1->refresh_table_display.
* Creating object for the single clickevents
if event_receiver_grid is initial.
create object event_receiver_grid.
endif.
set handler event_receiver_grid->handle_toolbar_200 for grid1.
call method grid1->set_toolbar_interactive.
set handler event_receiver_grid->user_command_200 for grid1.
module user_command_0200 input.
call method cl_gui_cfw=>dispatch.
case ok_code.
when c_ddno.
perform f__display.
when c_exit.
perform f_exit_program.
when c_back.
perform f_exit_program.
when c_canc.
perform f_exit_program.
when others.
endcase.
clear ok_code.
endmodule. " User_command_0200 INPUT
form f_display.
refresh: i_sel_alvrows,
i_dblclk.
clear : i_sel_alvrows,
i_dblclk,
wa_dblclk.
v_dbcnt = c_0.
call method grid1->get_selected_rows
importing
et_index_rows = i_sel_alvrows[].
call method cl_gui_cfw=>flush.
describe table i_sel_alvrows lines v_dbcnt.
if i_sel_alvrows[] is initial.
message i176.
endif.
if v_dbcnt gt 1.
message i177. " You cannot select more that one row
else.
loop at i_sel_alvrows into wa_sel_alvrows.
read table i_output into wa_output index wa_sel_alvrows-index.
if sy-subrc eq c_0.
move-corresponding wa_output to wa_dblclk.
append wa_dblclk to i_dblclk.
clear: wa_dblclk.
endif.
endloop.
endif.
endform.
aRs