on 05-30-2005 3:03 PM
Hello,
I have several ALV Grid Controls (cl_gui_alv_grid) in my application with some of them being editable and others not. I observed that the default selection mode for non-editable alv grids is some kind of 'single row' whereas for an editable alv grid it seems to be 'multiple row'.
Is there any way to unify the selection mode - 'single selection' preferred ?
I already tried all the available selection modes that can be passed via the layout structure but the 'multiple row' selection mode of the editable alv grids could not be changed...
Thanks in advance and best regards,
Patrick Baer
Hi Patrick
I do not know whether it is a bug or something intentionally done, but when you make the ALV grid editable, it set the selection mode to multiple selection. Or we might have both overlooked the same things...
Regards
*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Raja,
I have indeed checked out the sample programs and I agree with you that single selection is possible, BUT multiple selection is ALSO possible.
It's like single selection is a subset of multiple selection and on an editable alv you always seem to get mutliple selection and thereby of course also single selection.
In my case I only want the single selection subset.
If you got that to work I would be very interested to know how
Thank you anyway !!
Best regrads,
Patrick
Hi,
In PBO,
Set the Grid layout options
Title, Zebra, Mode, Optimise Width, Display variant
PERFORM f9400_layout using sy-title 'X' 'A' 'X' p_layout.
FORM f9003_layout USING value(ptitle)
value(pzebra)
value(pmode)
value(pwidth).
w_layout-grid_title = ptitle.
w_layout-zebra = pzebra.
w_layout-sel_mode = pmode.
w_layout-cwidth_opt = pwidth.
w_variant-report = sy-repid.
ENDFORM. " f9003_layout
If the selmode is A then u can make single selction in the normal case. <b>If u r using w_layout-edit = 'X' then by default multiple selection will come</b>.
<b>So it is not possible to restrict single selection</b>, in my requirement if we select multiple lines also we need to do calculation on a single row. In that case in get_selected_rows we have loop at the i_fieldrows and took latest record selected and did the calculation.
Thanks & Regards,
Judith.
Message was edited by: Judith Jessie Selvi
Hi Judith / Patrick,
i think you can't fix that problem with layout-sel_mode .
-> mode is set by the following method:
(look SET_READY_FOR_INPUT_INTERNAL in CL_GUI_ALV_GRID)
set_selection_mode_base exporting mode = l_mode.
(l_mode must be <b>1</b>)
but it's a <b>protected</b> method of class CL_GUI_ALV_GRID_BASE
regards Andreas
Judith,
I just wanted to answer your previous posting before you edited it
Tried out your sample code and as expected it showed multiple selection again. I tried it already before but put it in again just to make sure I was not mistaken.
In my initial posting I already kind of sensed there would be no solution for this but I thought 'ask the pros' first.
Now that we are three - including you and Serdar - I think we can kind of 'confirm' that single selection exclusive is not possible on editable alv grids.
Not the end of the world but far from ideal...
Best regards and thanks for the efforts of all who contributed to this thread !
Patrick Baer
Andreas,
everytime I'm writing an answer there is already a new posting - this group amazes me !
Just wanted to close this thread but somehow maybe there is a glimpse of hope.
What are you suggesting in your posting ?
Do you think it would be possible to derive a new class from cl_gui_alv_grid and change this one method and leave the others untouched to achieve an 'always exclusive single selection mode' ?
Best regards,
Patrick
I didnt understand the question fully - i was under the impression that the single select is not working. But later in your post you clarified, that you wanted <b>only</b> single select (in edit mode).
further investigation revealed that as Andreas has mentioned in edit more you loose the control over the sel_mode.
in method SET_READY_FOR_INPUT_INTERNAL
data: l_mode type i.
if is_ready_for_input( ) eq 1 and
( m_cl_variant->ms_layout-sel_mode eq 'B' or
m_cl_variant->ms_layout-sel_mode eq 'C' ).
l_mode = 0.
else.
case m_cl_variant->ms_layout-sel_mode.
when 'A'. "Row/Col-Select
l_mode = 0.
when 'B'. "Single Select Listbox
l_mode = 1.
when 'C'. "Multi Select Listbox
l_mode = 2.
when 'D'. "Full Select
l_mode = 3.
when others.
if is_ready_for_input( ) eq 0.
l_mode = 1.
else.
l_mode = 0.
endif.
endcase.
endif.
call method me->set_selection_mode_base
exporting
mode = l_mode.
Regards
Raja
Hello,
I just revealed a nice solution for me:
I derive a new class
cl_gui_alv_single_select
from
cl_gui_alv_grid
then I override the method
set_selection_mode_base
and rewrite it as follows:
CALL METHOD super->set_selection_mode_base
EXPORTING
mode = 1.
This is working nicely for me, maybe others find this useful too.
Best regards,
Patrick
Hi,
If u want to select multiple lines in the grid then in the layout w_layout-sel_mode = 'A'.
Also In the PAI of the screen
DATA: i_fieldrows TYPE lvc_t_row,
MODULE user_command_9001 INPUT.
CALL METHOD o_alvgrid->get_selected_rows
IMPORTING
et_index_rows = i_fieldrows.
LOOP AT i_fieldrows INTO w_fieldrows.
READ TABLE i_output INTO w_output INDEX w_fieldrows-index.
ENDLOOP.
CASE sy-ucomm.
WHEN 'XX'.
.
.
.
ENDCASE.
Try this out.This can be done in editable ALV too.
Also see this
http://www.sapdevelopment.co.uk/reporting/alv/alvscr.htm
Thanks & Regards,
Judith.
Message was edited by: Judith Jessie Selvi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
96 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.